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.

Code:

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 above code as a Shelf Tool.
It will reset the simulation, and restart it again from frame 1. Afterwards, the timestamp will be printed on the Python Shell like so:

timestamps

Timestamp output

Instead of using the Performance Monitor, I created this so as to avoid the (albeit small) overhead of the utility. (And as an exercise in using Python within Houdini)

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: