How to create a new node every 5 seconds in the network?

   1519   3   2
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
  1. I need to populate the network with new nodes at time intervals WHILE the user is interacting with Houdini.
    Ideally this should happen even during the cooking, or at least, the pending nodes should be created immediately after the cooking stopped. (note: the nodes wouldn't be connected upstream of the cooking branch)
    Is this possible to do?
    ScheduleTimerEvent [www.sidefx.com] seems to be suitable for this use case, but it's not really clear to me how I should set up the whole thing.

  2. The ultimate goal would be to have some sort of real-time listener for changes in a text file, that should trigger the node creation at every change in the file.
Edited by Andr - Oct. 19, 2021 14:38:26
User Avatar
Member
359 posts
Joined: April 2017
Offline
You might have an easier time using a QTimer for this.

Here's a really simple example:

from PySide2.QtCore import QTimer

def ping():
    print("PONG")

timer = QTimer()
timer.timeout.connect(ping)
timer.start(1000)

This will print "PONG" in your console every second, forever, so don't test it in a session you care about. Replace ping() with a more useful callback that checks files, modifies your network editor, etc.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Oh, thanks!
That helps but raises many more questions eheh

How is QTimer able to continuously run the function ping() without blocking the UI? Does it spawn a second process?
User Avatar
Member
359 posts
Joined: April 2017
Offline
I'm probably not qualified to explain exactly what's going on, but the QTimer is running within the same event loop that Houdini's own UI (which is Qt based) is running in. I haven't tested this, but this likely means that if the main event loop is blocked, the timer might also be blocked during that time. It's definitely not a separate spawned process.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
  • Quick Links