For example:
switch = hou.node("/obj/DA/Brick_Wall_DA/switch3")
If I now change the name from Brick_Wall_DA to something else the reference won't work.
It feels like it should be easy to fix but I cannot work it out.
Thanks in advance.
switch = hou.node("/obj/DA/Brick_Wall_DA/switch3")
switchvariable. You will need to eval()this parameter and then create a hou.nodereference from it.
ajz3d
Instead of hardcoding an operator path, create an "Operator Path" parameter and use it in yourswitchvariable. You will need toeval()this parameter and then create ahou.nodereference from it.
Then reference an existing operator from that parameter. Whenever this referenced operator's name changes, Houdini will update the parameter and the script will pull a new path from it.
Or, just use relative operator paths.
SWest
Hi, I’m on the move. Could you check the Python part in the docs. I wish this forum could focus on rather the next level. This I write with all respect, however, someone got paid to write the Puthon intro for the hou module.
If you do not find this answer there I will give it to you.
P.S. If doing Houdini Python is for you there will be a huge need to search docs from wherever you can. However, I suggest we all do our little homework”, if we are not under too much pressure, before asking here. Just referring to the most basic things. (And also I do teach programming fundamentals at high school, and know the drill)
Edit: https://www.sidefx.com/docs/houdini/hom/index.html [www.sidefx.com]
Edit2: For myself I spent years to understand programming, done courses, teach basics, and still have to do effort to get anything done with Houdini. It is because one has to get a grip of the API as well as understanding Python fundamentals.
# this node (relative) this_node = hou.node('./') print(this_node) print(this_node.path()) # some parm hou_parm_path = this_node.path()+'/b_int' hou_parm = hou.parm(hou_parm_path) print(hou_parm.eval())
SWest
Sure, there are many very helpful people here who share similar interests. Just learning to dig into technical things can be fun, as well as sharing knowledge.
Here you go:# this node (relative) this_node = hou.node('./') print(this_node) print(this_node.path()) # some parm hou_parm_path = this_node.path()+'/b_int' hou_parm = hou.parm(hou_parm_path) print(hou_parm.eval())
Try that.
jacobtitheridge
Could you explain what you mean by create an Operator path parameter, or just how I would use relative operator path?
SWest# this node (relative) this_node = hou.node('./') print(this_node) print(this_node.path()) # some parm hou_parm_path = this_node.path()+'/b_int' hou_parm = hou.parm(hou_parm_path) print(hou_parm.eval())
hou.node('./')# PythonModule def test(): hda = hou.pwd() switch = hda.node('switch1') print(switch.path()) print(switch.parm('input').eval())
ajz3d
O
jacobtitheridgeYes,
I got too stuck on why hou.pwd() was returning just "/" to think to try it.
hou.pwd()returns the current path (or prints "current working directory" if we were to speak in GNU/Linux terms). When you call it from within an HDA or any other node, it will return their paths. It returned a hou.Nodeat "/" because you were calling it from "/".>>> hou.pwd() <hou.Node at /> >>> hou.cd('/obj/geo1/box1') >>> hou.pwd() <hou.SopNode of type box at /obj/geo1/box1>
ajz3djacobtitheridgeCan you elaborate? I don't see why kwargs wouldn't work.
You cant reference kwargs within the python module on a hda for some reason so I will need to use this method. Thank you so much.
# Button's callback script: hou.phm().no_kwargs() # PythonModule def no_kwargs(): print(kwargs)
{'type': <hou.SopNodeType for Sop test::1.0>}# Button's callback script: hou.phm().test_kwargs(kwargs) # PythonModule def test_kwargs(kwargs): print(kwargs)
{'node': <hou.SopNode of type test::1.0 at /obj/geo1/test1>, 'parm': <hou.Parm kwargs_button in /obj/geo1/test1>, 'script_multiparm_index': '-1', 'script_value0': '0',
'script_value': '0', 'parm_name': 'kwargs_button', 'script_multiparm_nesting': '0', 'script_parm': 'kwargs_button'}