Cooking top nodes by script

   3772   3   2
User Avatar
Member
577 posts
Joined: Nov. 2005
Offline
Hi, I try to cook nodes with a python script, but … well, it could run better

I attached a file. I would like to open that file and run this python script:
top = hou.node('/obj/topNet/wedge1')

print top.path()
top.setDisplayFlag(True)
top.getPDGNode().cook(True)
work_items = top.getPDGNode().workItems
print (work_items)

when You run it directly after opening the file, it fails, top.getPDGNode() results in None.
after cooking the top nodes with the ui and deleting the results, the script works.
I wonder, what is going on here. Tt seems that a initial cool by hand, does initialize something so the getPDGNode does work. How can I do this?

thanks for any hints
Martin

Attachments:
wedge.hip (66.0 KB)

User Avatar
Staff
600 posts
Joined: May 2014
Offline
That's because the PDG node graph does not exist until the TOP nodes have cooked – TOP nodes generate the PDG graph. The best way to achieve what you want is to use the TOP Node's execute graph function: https://www.sidefx.com/docs/houdini/hom/hou/TopNode.html#executeGraph [www.sidefx.com]

That will ensure that the TOP node is cooked before attempting the cook the PDG graph, and exposes various options to control the cook. That's what the TOP Fetch node uses, for example, to cook an external TOP network. You can see the implementation of that in $HH/python2.7libs/pdg/job/top.py
User Avatar
Member
577 posts
Joined: Nov. 2005
Offline
Thank You!
EDIT:

The “executeGraph” method works fine in a running session, all the PDGNodes are accessible. But I tried to use it in a hda “on loaded” event and again, I get a None back from “getPDGNode” method
The “exectueGraph” method seems to have no effect in a “on loaded” event
is there a way to get that running in this kind of event?
Edited by sanostol - April 10, 2020 08:39:50
User Avatar
Member
4 posts
Joined: June 2013
Offline
Hi Martin,

I have the same problem now in h18.5 to executeGraph() "onLoaded" event in HDA.

Have you found any solution?

Thanks,

MacPla
  • Quick Links