Jump to content

Where to put hscript commands?


Recommended Posts

Hi there,

I'm trying to run hscript commands at different points in my animation, including calling tk and manipulating objects. How is this done without typing it into the textport? Where do you put scripts/commands that will run at certain times?


Christine Smith

Northrop Grumman

Engineering Visualization Resource

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hi Christine,

You can run any script pretty much anywhere you want. For example, you could put it in an unused channel. Let's say you had a simple script in $HOME/houdini7.0/scripts you wantred to run, let's call it "testmessage.cmd" that has this in it:

message This is frame $F

That's all it does ;)

So, if you type "testmessage.cmd" in the textport it tells you what frame you're on.

Now, all you have to do is create a little wrapper custom expression. Open up the Alias/Variables dialog, and go to the Expressions tab.

Type this in:

runner(float curframe, frameToRun)
    if(curframe == frameToRun)

Now, you can use the runner() expression in an unused channel. For example, I used the Renderman Cs in an Object, since I am not using Renderman, I don't need it. I just enter:

runner($F,50) and on frame 50 the script is run!

You have to wrap the running of the script in a custom expression, or else the script is run at times you don't want. When testing this, I first tried:

if($F == 50, run("testmessage.cmd"), 0)

however, this runs the testmessage.cmd A LOT which is annoying. The custom expression is the way to go.

Actually, now that I think about it, here's what the expression should really be:

runner(float curframe, frameToRun;
        string script)
    if(curframe == frameToRun)

So you then have a generic "runner" script that takes the current frame, the frame you want to run the script on, and the script itself, like so:

runner($F, 50, "testmessage.cmd")

Much more useful.


Peter B

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.

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...