I've had some success being able to execute a preflight top node via a right click menu.
I realised though that I needed to ensure the python script wouldn't continue to execute the primary top stream though until the preflight finished cooking.
the nasty way would be to use cook(True), but this isn't great because it locks up the ui which is no good.
What would the recommended / best way be to execute the next stage after preflight completed?
I thought it would be something like adding an event handler (is this a callback?). if thats the best way, I wasn't able to get it to work in this very simple example, which should print “done”, when the node (top preflight stream) finished cooking.
If that is the right way to do it, do you have any suggestions on how I would get it to work?
>>> def done(node):
... print "done", node
...
>>> pdg_node = hou.node('/obj/geo1/topnet1/genericgenerator6').getPDGNode()
>>> pdg_node.addEventHandler(done(pdg_node), filter=pdg.EventType.CookComplete)
done <_pdg.genericgenerator name='genericgenerator6'>
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: addEventHandler(): incompatible function arguments. The following argument types are supported:
1. (self: _pdg.Node, arg0: object) -> _pdg.EventHandler
2. (self: _pdg.Node, arg0: object, arg1: _pdg.EventType) -> _pdg.EventHandler
Invoked with: <_pdg.genericgenerator name='genericgenerator6'>, None
I wanted to note though, I think mappers should be able to do this. the only reason why this is being built instead of using something like a mapper, is that mappers will always pass the dirty/parent changed state downstream, which in the case of a preflight run is bad, because preflight is almost always dirty, and it shouldn't regenerate items downstream if they are on disk.
it would be great if all mappers / the waitfor all node had a tick box to not dirty downstream items, this seems to be the kind of thing mappers should be able do by extension (define relationships between two parts of a graph where workitems aren't being passed through).
By the way, the spelling of eventType in this doc should be EventType
https://www.sidefx.com/docs/houdini/tops/pdg/eventType.html [
www.sidefx.com]
…I was wondering why it initally was not an object from following the docs