Posted by: Jeff | 2017/04/27

Houdini: Simulation Timestamp

This is a short python script that I’m currently using to print out the total simulation processing time of the current DOP network.

timestamps

Timestamp output

import datetime

def simTimeStamp(event_type, frame):
    global tStart, tEnd
    if event_type == hou.playbarEvent.FrameChanged and frame == 1:
        hou.playbar.play()
    if event_type == hou.playbarEvent.Started:
        tStart = datetime.datetime.now()
    if event_type == hou.playbarEvent.Stopped:
        tEnd = datetime.datetime.now()
        tDelta = tEnd - tStart
        print "Simulation time:", tDelta
        hou.playbar.removeEventCallback(simTimeStamp)

hou.playbar.addEventCallback(simTimeStamp)
hou.currentDopNet().parm('resimulate').pressButton()

if hou.frame() == 1:
    hou.playbar.play()
else:
    hou.setFrame(1)

Run the code as a shelf tool.
It will reset the simulation, and restart it again from frame 1. Afterwhich, the timestamp will be printed on the python shell.

I created this instead of using the Performance Monitor so as to avoid the overhead of the utility.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: