Jump to content

Rname Otl On Created


Recommended Posts

Hello,

I'm working on a "Null" otl that I want to append to the end of my network.

When the operator is created I want to change the name of the operator.

In the On Created Event Handler I have the following script/expression

opname `opname(".")` `opname("..")`_OUT

To my understanding, this should rename this operator to the name of the object this is inside and with a suffix of "_OUT". So if this was in /obj/model, this operator would now be called model_OUT.

The problem is, this event script does nothing when the operator is created?

Any ideas what I'm doing wrong here?

Cheers,

/Rick

Link to comment
Share on other sites

hey rick,

unfortunately with opname, "." doesn't exist yet (for the otl) when on created (atleast i think that's what's going on here.. could be wrong so maybe someone else can enlighten us on that..). oddly enough "`opname(".")`" gives us access to the node the otl is being created in.. which is a real crapper since I can't figure out how to access the next level down without specifying the exact name of the otl to change (which defeats the whole purpose of this being relative and procedural and what not).. luckily what does happen whenever you throw down a node in the chain is that it get's selected.. so we could use opselect(".") in order to get a basis for the rename.. try the following instead:

opname `opselect(".")` `opname(".")`_OUT

hth,

dave

Link to comment
Share on other sites

Thanks Dave, your solution is clever!

Thanks Simon also! Funny thing is, last night before I posted here, I did read the help card on this and noticed $arg1, $arg2 but I remember thinking, I don't want to send command line args to this otl. I totally misinterpreted this.

Works good now!

Cheers,

/Rick

Link to comment
Share on other sites

I have another question that's somewhat related to this.

How would i go abouts changing the opname of the default file sop?

I would prefer for it to have the base name of the geometry file when the user supplies it.

I know I can create an otl for this but I'm wondering if I can have a script bound to the file sop in my $HOME/houdini8.0/scripts folder rather than the houdini install directory?

I checked creation scripts in the help browser but I don't think that's it, I think I need an onUpdated script but I'm not sure if it's available for the standard sops.

Cheers,

/Rick

Link to comment
Share on other sites

nice simon! will definitely keep that tucked away in the back of my head somewhere..

as for the file sop.. i always thought you could put a file in your scripts folder that is called nameofop.cmd and that would get sourced every time you layed that op down.. so in this case, it would be file.cmd but it doesn't seem to be working at all.. will poke around about this to see what i can find..

the other thing is you can open any standard houdini op and go to it's type properties and hit accept.. this will put a creation script for it in your $HOME/houdini8.0/otls/OPcustom.otl file. So do that for the file sop and you will see the creation script down at the bottom.. feel free to add anything you want in there to customize it.. the only problem is that this doesn't help much considering it's a creation script and will always be at the parm that it's set at in the begining..

hmmm.. will keep thinking and digging..

Link to comment
Share on other sites

the other thing is you can open any standard houdini op and go to it's type properties and hit accept.. this will put a creation script for it in your $HOME/houdini8.0/otls/OPcustom.otl file. So do that for the file sop and you will see the creation script down at the bottom.. feel free to add anything you want in there to customize it.. the only problem is that this doesn't help much considering it's a creation script and will always be at the parm that it's set at in the begining..

25573[/snapback]

This I didn't know! This bit will help me later when I want colors to be set on ops on creation.

I think what I want with the filesop is not possible without either an otl or running a script each time I want this to happen rather than automatically. I "think" :blink:

Link to comment
Share on other sites

yeaaaa... ;)

but while we're on the topic and going back to Rick's issue.. is there a way to pull out the parameter value (string) of the filename in order to stuff it in the name of the op.. i was thinking of strreplace'ing the non-needed info a opparm spits out but that just seems out the way.. you know of any way to just quickly get a value of a parm and stuff it into a variable? maybe eval() the chs() of it? I dunno.. probably still won't help since we can't seem to get past the creation part of it.. :rolleyes:

Link to comment
Share on other sites

yeaaaa... ;)

but while we're on the topic and going back to Rick's issue.. is there a way to pull out the parameter value (string) of the filename in order to stuff it in the name of the op.. i was thinking of strreplace'ing the non-needed info a opparm spits out but that just seems out the way.. you know of any way to just quickly get a value of a parm and stuff it into a variable? maybe eval() the chs() of it? I dunno.. probably still won't help since we can't seem to get past the creation part of it..  :rolleyes:

25593[/snapback]

extracting the relevant data is easy, getting it to change the sop name onUpdated with the standard filesop is the hard part ;)

set myval = `strreplace(chs("file1/file"), ".bgeo", "")`
echo $myval
defgeo

No worries though, I guess a file otl is the way forward. I just wondered if there was a simple approach rather than creating an otl. My problem with otls is I get a little overboard and start adding some funky parameters/scripts/expressions to calculate the end of the world :P

Thanks!

/Rick

Link to comment
Share on other sites

well yea.. kind of easy until you get to harder file names it seems.. :) strreplace is nothing like a solid sed in linux unless i'm completely missing out on some really coolio functions.. with defgeo.bgeo, it's easy.. but what if you have it pointing to /foo/bar/test/name-of-my-file.bgeo.. you'd have to strreplace(strreplace(strreplace())) just to get rid of the non standard chars in that example, but it really doesn't seem to be bullet proof to whatever you would want to throw at it.. not to mention you'd have this long name now.. i would like to just set something up that would rename it to "name_of_my_file" and be done with it no matter what i put in there.. i could be missing something big time so i'd love to know how to do better string stuff in hscript/expressions because i get the feeling that i'm doing something wrong.. :rolleyes:

but anyways.. i got this far but it hits a point.. a dead end really.. a standing rfe dead end to be exact.. ok, so here is what you can do with events on normal nodes..if you go to your operator type manager and hit edit contents, you can put in your onUpdated and what not in there.. I think you can do it in the regular type properties, but it seems to stay sometimes, and other times not.. this method seemed to work full proof each time and stayed after closing houdini and reopening.. so:

1. Operator Type Properties

2. Edit contents (in this case: ./otls/OPcustom.otl->Sop/file)

3. Create Section Name (i.e. onUpdated)

4. Hit Add Empty Section button

5. Put script in:

set filename = `strreplace(chs("$arg1/file"), ".bgeo", "")`
opname $arg1 $filename

6. Hit apply, accept, etc..

That should do it.. Now.. why is this worthless.. well it's worthless because you'd have to pop open your type properties and hit accept for the onUpdated event to trigger.. All other events are pretty much useless to us at this point as well.. So i did some searching because I kept thinking "I just need an onCook event or something.. I know there's gotta be one..." And that's when I came across a thread over at the sesi forums where our good friend Simon even pointed out that an onCook type event has already been RFE'd by himself..

So at this point we cry.. Curl up in to the fetal position and find a corner.. Well atleast until sesi can give us some sort of on onCook deally.. that or until one of the super guru's come's by here and tells us how to magically do it with what is already there.. because i do agree.. creating otls for this and otls for that can get old (and still wouldn't do us much good without an onCook..)...

dave

Link to comment
Share on other sites

I have indeed RFE'd it, it would be so sweet, but so far no dice.

By the way one way of dealing with /obj/foo/name/myobj.bgeo is to use rindex to find the position of the last / you can then use substr to grab just the last myobj.bgeo part. It may not be useful in this case but it is else where.

Link to comment
Share on other sites

Hey David,

Thanks for the reply and hunting this down.

well yea.. kind of easy until you get to harder file names it seems.. :) strreplace is nothing like a solid sed in linux unless i'm completely missing out on some really coolio functions.. with defgeo.bgeo, it's easy.. but what if you have it pointing to /foo/bar/test/name-of-my-file.bgeo.. you'd have to strreplace(strreplace(strreplace())) just to get rid of the non standard chars in that example, but it really doesn't seem to be bullet proof to whatever you would want to throw at it.. not to mention you'd have this long name now.. i would like to just set something up that would rename it to "name_of_my_file" and be done with it no matter what i put in there.. i could be missing something big time so i'd love to know how to do better string stuff in hscript/expressions because i get the feeling that i'm doing something wrong..  :rolleyes:

I hear ya. If I need some heavy duty string parsing, I'll just do a system call.

Last night I was working pretty late on a geo cache otl with script and I had to parse the hip file.

I try to use and enforce strict naming conventions. The hip is usually Hipname_version. Hipname can be ShotNum_Sequence_ext. As long as we are consistent. In any case, my example hip was Workflow_v01.hip. Here's some sampe code to extract the data I need:

# Extract just hip name without the .hip
set SCENE = `strreplace($HIPNAME, ".hip", "")`

# Extract the file version which is after last underscore
set Tag = `strreplace(substr($HIPNAME, rindex($HIPNAME, "_")+1, strlen($HIPNAME)), ".hip", "")`

# Extract the time and replace : with underscores
set Time = `strreplace(arg(system(date),3), ":", "_")

# Get the base name of the hip
set Pre =`substr($SCENE, 0, index($SCENE, "_"))`

Not pretty but it works ;)

but anyways.. i got this far but it hits a point.. a dead end really.. a standing rfe dead end to be exact.. ok, so here is what you can do with events on normal nodes..if you go to your operator type manager and hit edit contents, you can put in your onUpdated and what not in there.. I think you can do it in the regular type properties, but it seems to stay sometimes, and other times not.. this method seemed to work full proof each time and stayed after closing houdini and reopening.. so:

1. Operator Type Properties

2. Edit contents (in this case: ./otls/OPcustom.otl->Sop/file)

3. Create Section Name (i.e. onUpdated)

4. Hit Add Empty Section button

5. Put script in:

set filename = `strreplace(chs("$arg1/file"), ".bgeo", "")`
opname $arg1 $filename

6. Hit apply, accept, etc..

That should do it..

Wicked! I'm gonna try it later today. Cheers

So at this point we cry.. Curl up in to the fetal position and find a corner.. Well atleast until sesi can give us some sort of on onCook deally.. that or until one of the super guru's come's by here and tells us how to magically do it with what is already there.. because i do agree.. creating otls for this and otls for that can get old (and still wouldn't do us much good without an onCook..)...

Yup, onCook would be great. In my adventures last night, I needed to rename the otl to some variation of the sop that's connected to it. I tried all the onCreated, onLoaded, onUpdated with no luck. I ended up creating an invisible toggle parm called setName with the following callback:

opname `oppwf()` `toupper(opinput(".",0))`_GEO_CACHE

In the onInputChanged event I put:

opparm -c $arg1 SetName 1

Why I can't just set the name in onInputChanged beats me? In any case, calling this hidden param seems to work.

Cheers!

/Rick

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