Jump to content

how to set unexpanding string to parameter by python


tagosaku

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

Link to comment
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

Link to comment
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.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...