Search - User list
Full Version: (SOLVED) Script run PDG and wait for it to finish before continuing
Root » PDG/TOPs » (SOLVED) Script run PDG and wait for it to finish before continuing
JohnDoe777
Hello,

I'm trying to run a python script where a part of it needs to press the tops network button and wait for it to finish(or times out) before continuing with the rest of the script. I've tried a timer but that doesn't work as it freezes Houdini, I tried using a seperate thread which did keep checking the node but the script being in the main thread just kept going and using thread.join() just causes Houdini to either crash or freeze for good.


import hou
import time

node = hou.selectedNodes()[0]

hip = hou.hipFile.path()
hou.hipFile.save(hip)
node.parm("cookbutton").pressButton()
time.sleep(2)

cooking = True
failed = False

while cooking:
    for i in range(60):
        if node.getCookState(1) != hou.topCookState.Cooking:
            print("Cook finished")
            cooking = False
            break
        time.sleep(2)
    if node.getCookState(1) == hou.topCookState.Cooking:
        print("Times up")
        failed = True
    cooking = False

print("Continue the rest of the script")
Thanks
AslakKS
You can cook TOP nodes and have them block Houdini while it runs.
A few different flavors: [www.sidefx.com]
JohnDoe777
Thank you this was exactly what I was looking for!
BillTarner
Precisely the best option available, it remains in this case to cook the TOP nodes, and to start the process of blocking Houdini itself, at the moment of its eventual action. This should help you, I too have used such an option many times before.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB