Rebuilding network from python code. Compatibility issues

   1484   2   1
User Avatar
Member
46 posts
Joined: March 2015
Offline
Hey there,
I'm new to python and coding in general…

I'm playing with asCode method for nodes. Everything seems to be working fine unless I try to execute the code in another Houdini version.
For example, if the code is generated in Houdini 18 and then executed in Houdini 17 it will generate an AttributeError.
The reason is some parameters just don't exist on the same node in different Houdini versions, in particular attribute wrangle “vex_precision” parameter that only exists in Houdini 18.

So this is how error looks like when I execute the code in H17 that was generated in H18:

AttributeError: 'NoneType' object has no attribute 'lock'

And here is the block of code where error occurs:
# Code for /obj/geo1/subnet1/pointwrangle1/vex_precision parm 
if locals().get("hou_node") is None:
    hou_node = hou.node("/obj/geo1/subnet1/pointwrangle1")
hou_parm = hou_node.parm("vex_precision")
hou_parm.lock(False)
hou_parm.deleteAllKeyframes()
hou_parm.set("auto")
hou_parm.setAutoscope(False)

I wonder if there is a way to bypass that error or anything that helps to fix this problem.
Thanks !

Attachments:
compatibility_test_network.py (8.8 KB)

User Avatar
Member
7938 posts
Joined: Sept. 2011
Offline
I wouldn't try to run code that creates nodes in an older version of houdini for exactly this reason, you may be able to bypass the parms that don't exist, but the network may not work as expected.

If you just want to skip parameters that don't exist, then add a check before they're used.

e.g.

hou_parm = hou_node.parm('glipglop')
if hou_parm:
  do hou_parm stuff
User Avatar
Member
46 posts
Joined: March 2015
Offline
Thanks Jonathan,

I’ll try it out! Though it might be a bit tricky for me how to modify every block of code describing a parameter.

Cheers!
  • Quick Links