Jump to content

Event scripts; Running something after open


Recommended Posts

Like with the 456.cmd script, I want to execute some hscript from a custom operator and modifying the nodes' parameters. How do I do that?

Kinda like the "Before First Created" event script, but I need the node to have been created so that I can opparm its parameters around.

The "On Created" event script is closer, but this event script not run when just opening hipfiles.

The "On Updated" is also close, but the definiton is not being updated. I want to do this religiously for every time I open the hipfile.

I am resistant to putting special-case code in the 456.cmd - is there a way to do this?

Thanks,

Jason

Link to comment
Share on other sites

Hey Jason,

I think this should work... at least worth a try anyway.

Add a section to your OTL and call it CreateScript. (just like that; mind the caps ;) )

This is a script that runs every time the optype is instanced and, AFAIK, runs immediately after initialization -- basically the "123.cmd" for each OP.

The script is passed the name (full path I believe) of the op; so the begining of the script would typically look something like this:

if ( "$arg1" == "" ) then
    echo This script is intended as a creation script
    exit
endif
opparm $arg1 std_switcher_0 ( 1 )

In other words, it's no different than your standard creation script (like the ones in $HH/scripts) that run for the factory OPs. The above fragment for example, just changes the initial active parameter tab for one of my OPs (so it shows tab 1 at startup, instead of tab 0 which is the default).

Anyway; as you can see, you can use opparm on the OP ($arg1) in the script... which is what you want, right?

Cheers!

P.S: Oh, almost forgot; I don't think you can add this script as an event handler through the Type Properties dialog; you have to do it manually through OperatorTypeManager->EditContents. (though maybe it's there in 7.0 -- running 6.1 at the mo... rfe maybe?)

Link to comment
Share on other sites

Hey Mario,

I'm not in front of Houdini right now, but isn't this only run at inital creation time? I thought I tried this with a simple "message CREATED" command and it only did it when I put down the op for the first time, and not every time I loaded the file.

Thanks,

jason

Link to comment
Share on other sites

hmmm...

I thought otload might help...but it doesn't...

I think what you're looking for is an event like "onOtload " - so that when Houdini loads an OTL into the manager it runs a script etc...this doesn't require that the OTL be instantiated...

Link to comment
Share on other sites

I'm not in front of Houdini right now, but isn't this only run at inital creation time?

Ah yes... OK. No good then.

I guess there's no instantiation going on during a load -- all OPs must be simply loaded as raw data...hmmm... then none of the "instance" scripts (OnCreated/Updated/Deleted, etc) would work since there are no OP-related events being triggered (just guessing here). Which would leave only the OTL-related events, like "BeforeFirst", which are instance-less... and yet you need an instance to exist before you can "opparm" anything <_<

Is this to modify (on-load) some kind of "template" hip that needs to get customized for different purposes?

Because if it's just a fixed set of OPs that change on each load, then maybe you can create a sort-of "trojan" otl with a "BeforeFirst" handler that does nothing more than opread some pre-saved OPs, or source some external scripts, or whatever -- i.e: it "pushes" all initialization setup into the hip that's currently loading....

hmmmm... tricky, this...

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