hou.hscriptExpression() not take arguments right

   1915   1   0
User Avatar
Member
7 posts
Joined: 1月 2012
Offline
Hello, I'm Trying to put together a python script and for some reason hou.hscriptExpression() isn't returning the value right.

This what i'm sort of using.

Fed into the argument is 'ch(“/obj/geo2/carve1/valve”)' or 'ch(“valve”)'

def foo(valveIO)
    valveCh = hou.hscriptExpression('\'{value}\'') .format(value=valveIO)
    return valveCh

Testing it in the shell

valveIO = 'ch("/obj/geo2/carve1/valve")'
valveCh = hou.hscriptExpression('\'{value}\'') .format(value=valveIO)

returns on print ch(“/obj/geo2/carve1/valve”) rather then the value in that channel.


btw without the “\'” before {value} i'll get a “inline (1): Syntax error in assignment”

Now if I just run hou.hscriptExpression('ch(“/obj/geo2/carve1/valve”)') it does return the correct int value.

Is this something that can't be do in python or am I just going about this wrong?
Edited by enderki - 2016年6月24日 12:06:41
User Avatar
Member
2629 posts
Joined: 6月 2008
Offline
Here is how you can fetch and set parameters directly in Python without using HScript.
my_node = "/obj/geo2/carve1"
current_value = my_node.parm("valve")
current_value += 1
my_node.parm("valve").set(current_value)
Edited by Enivob - 2016年6月24日 13:25:57
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
  • Quick Links