Jump to content

Python callback button trigger every frame


Recommended Posts

You can add a callback to the playbar. 

def outputPlaybarEvent(event_type, frame):
	# Code here.
	print ("Playbar event", event_type, "at frame", frame)
        
hou.playbar.addEventCallback(outputPlaybarEvent)

Or the Pre-Frame event of a ROP. Code inside the playbar callback won't update when you're rendering.

import hou

frame = int(hou.frame())
print(frame)

 

Edited by Atom
Link to comment
Share on other sites

Put the playbar code in a shelf tool, and click the button. Scrub the timeline to observe the print statement. To embed it in a hip file, so it runs every time the file is opened, place the code inside the source editor. You can open the editor under the Windows/Python Source Editor menu along the top of the Houdini app. 

Edited by Atom
  • Like 1
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...