(SOLVED) Script run PDG and wait for it to finish before continuing

   1737   3   3
User Avatar
Member
36 posts
Joined: Dec. 2014
Offline
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
Edited by JohnDoe777 - Sept. 15, 2023 10:49:52
User Avatar
Member
185 posts
Joined: Feb. 2016
Offline
You can cook TOP nodes and have them block Houdini while it runs.
A few different flavors: [www.sidefx.com]
Edited by AslakKS - Sept. 15, 2023 09:26:58

Attachments:
firefox_vdnI6aY6jE.png (173.5 KB)

User Avatar
Member
36 posts
Joined: Dec. 2014
Offline
Thank you this was exactly what I was looking for!
User Avatar
Member
3 posts
Joined: Sept. 2023
Offline
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.
  • Quick Links