Jump to content
Sign in to follow this  
kramer3d

Detecting incomplete node definitions in python

Recommended Posts

Hi all,

I need to do some pipeline related processing of nodes in case their asset library goes missing.

Is there any way to detect missing HDA definition programmatically in python? Some sort of callback on scene load would suffice, can someone please give me a hint?

Alternatively, given a hou.Node instance, is there a reliable way to tell whether it's using complete definition?

Edited by kramer3d

Share this post


Link to post
Share on other sites

Try to get a definition instance (node.type().definition()) and call some methods of it. I'm pretty sure you'll get an exception somewhere and so try-except would be your answer.

As for auto detect, see 456.py startup file, where you could iterate over all node types and check their definitions (see hou.hda.loadedFiles() example in the docs).

Share this post


Link to post
Share on other sites

Short of using some wrapped HDK code, I think the best bet to check for a dummy definition is to check that both the libraryFilePath() points to "Embedded" and that the definition has very little in the sections() list.

For example, creating a HDA on disk from a SOP Subnet yields a definition with some expected sections:

>>> asset = subnet.createDigitalAsset("dummyop", "/var/tmp/dummy.otl", "Dummy")
>>> node_type = asset.type()
>>> node_type.definition().sections()
{'Contents.gz': <hou.HDASection Contents.gz in definition of Sop dummyop in /var/tmp/dummy.otl>, 'CreateScript': <
hou.HDASection CreateScript in definition of Sop dummyop in /var/tmp/dummy.otl>, 'InternalFileOptions': <hou.HDASe
ction InternalFileOptions in definition of Sop dummyop in /var/tmp/dummy.otl>, 'DialogScript': <hou.HDASection Dia
logScript in definition of Sop dummyop in /var/tmp/dummy.otl>}
>>> node_type.definition().libraryFilePath()
'/var/tmp/dummy.otl'

However, if you then destroy the definition (with an instance of the node in your scene) you'll see it now reports as "Embedded" and only has a DialogScript and Contents.gz section:

>>> node_type.definition().destroy()
>>> node_type.definition().sections()
{'DialogScript': <hou.HDASection DialogScript in definition of Sop dummyop in Embedded>, 'Contents': <hou.HDASecti
on Contents in definition of Sop dummyop in Embedded>}
>>> node_type.definition().libraryFilePath()
'Embedded'

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×