Jump to content
tagosaku

how to set unexpanding string to parameter by python

Recommended Posts

Hi, I am studying python to set a parameter of string (cachePath) by script.  After executing the code,  ideally it pastes original, "`chs("resouceA")`_`chs("resouceB")`", instead of expanded result "G:/Projects/RnD_000_001/geo_element "

So far, I am thinking two methods:


a = r(\"\`chs(\"resouceA\")\`_\`chs(\"resouceB\")\` ")
# this way is too many back splash and so confusing

B
resA = hou.node('.').parm('resourceA').unexpandedString()
resA = hou.node('.').parm('resourceB').unexpandedString()
a = resA + resB
# this way is ok, but when there are 5-10 parmeters, it would be too much work. 

 

Do we have a simplest way or special command?? Ideally something like this:
a = unexpandedExpression("`chs("resouceA")`_`chs("resouceB")` ")
Thanks

 

image.png.1066d7dafab1705072485c72c736631e.png

Share this post


Link to post
Share on other sites

There's no direct method AFAIK. 

I don't understand the purpose of doing this. The whole point of channel reference is that if either of resourceA or resourceB is changed, it will be updated automatically in your cachePath. Instead of getting the unexpandedstring and setting them, why don't you just evaluate the parameter and set the value directly ?

 

-J

Share this post


Link to post
Share on other sites

>> I don't understand the purpose of doing this

This is just for a test, and I want to study how much we have option with python. 

 

>> why don't you just evaluate the parameter and set the value directly ?

For example, $F4, as frame number, we don't want to put the result of evaluation. Houdini should automatically update $F to number. It also can produces substep numbers, but not python. I already know we can write \$F to make unexpanding in python.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×