I think what you are after is how to install a python parameter expression on a string parameter.
Right-click in the Parameter label, and do Edit Expression. Write anything in there and click ok. You should see the parameter text background turning green. This tells you you have an hscript expression installed. Right-click again and Set Expression Language to Python. The text background should turn purple. Now, you have the choice of writing a single line expression, or a multinline one. You won't need to call eval() or hou.parm().set() to change the parameter value.
You just need to write python code that returns a string for a single line expression.
For multiline expression, you can use the return statement to return a string from any lines. It acts a bit like a function without the def line.
I thought I would post here in this recent thread since what I am asking is similar but am having problems implementing.
I've tried doing what rvinluan suggested. But in my case the parameter I am referencing is an operator path that is referencing the desired paramter.
I have it set up this way as it reflects something I want to do with a digital asset. In my hip attachment I've simplified the set up with a subnet in the material network.
I've tried the following which doesn't work:
Result = 1
if(ch("../toggle_use_uv_node") == 0): Result = ch("../uv_alt_constant")
if(ch("../toggle_use_uv_node") == 1): My_Ref = hou.parm(expandString('../uv_node_reference')) Result = My_Ref.eval()
return Result
I've done some net searches but can't seem to find enough info and getting this to work.
Had a bit of trouble to get it to work, but when I realized I should have removed the ‘su’ reference from the operator path parameter, ie. changing it back to
../../uvtexture1
from
../../uvtexture1/su
..then it worked.
Will have to keep this file with code for future reference until I am much better at knowing how to navigate through the hou docs.