Jump to content

Detecting incomplete node definitions in python


kramer3d

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
Link to comment
Share on other sites

  • 2 weeks later...

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).

Link to comment
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'

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...