Jump to content

NetworkUIUpdate - Threading + Timer


Recommended Posts

Hey there,

I've been struggling trying to understand houdini's event loops and getting around updating a networkview some timestep. I also haven't been able to find docs about hdefereval. So was curious if anyone might have any tips on how to update function to evaluate some X timestep. As this seems to be almost pseudo random updates but I probably don't understand some foundational knowledge of threads and processes.


Here's an attempted example of a node updating pos, every x time. but its not quite right. (press enter to cancel out of in python shell, and I recommend not running too long as I assume there's more going on than I realize)

 

import hou
import threading
import time
 
def create_object():
    obj_node = hou.node("/obj")
    geo_node = obj_node.createNode("null", "test_object")
 
def object_move():
    geo_node = hou.node("/obj/test_object")
    geo_node.move((0, 0.5))
 
def update_thread():
    cancel = False
 
    def update():
        if cancel:
            return
 
        print("Update function called")
        object_move()
        timer = threading.Timer(.1, update)
        timer.start()
 
    timer = threading.Timer(.1, update)
    timer.start()
    input("Press Enter to cancel the thread")
    cancel = True
    timer.join()
 
create_object()
update_thread()

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...