Jump to content

Chcp


Visual Cortex Lab

Recommended Posts

Hi Guys...

sorry for the noob question but... I'm not going far and I need your help :)

I looked the the help but ther's no example.. so I wonder where my syntax is wrong..

what i need is to copy animations channel from an Object to another (Since collada doesnt really help me.. but at least it have the animations I need from the objects)... so I'm looking for the easier way to copy/paste animations from/to objects.. planning to put the solution in a script.

I was looking at the "chcp" command.. but it seems i cant find the way to use it..

/obj -> chcp /obj/Model/ctl_position/tx /obj/my_camera/camera_translationx
Cannot find source channel /obj/Model/ctl_position/tx

i also tried with ch("/channelname") but it gives me "wring usage"

can anyone point some light on this?

also .. any hints about this task is welcomed :)

XSI -> houdini is the workflow I'm on now.

cheers

Link to comment
Share on other sites

ok.. i found the real problem... the syntax is ok .. but I'm trying to copy parameters from a HDA or a Subnet to another... and in this case I've got problems...

seems like subnets or HDA doesnt expose any parameters...

for example..

LQ_XSIcamera is my HDA which I created a Camera Rig where I wish to copy on my XSI camera animation/settings... it have the parameters and so on..

/obj -> ls
LQ_XSIcamera

but when i try to list the channels from that node (the HDA itself which have the parameters)

/obj -> chls LQ_XSIcamera/
/obj ->

any idea?

Link to comment
Share on other sites

Are they keyframed values or just a flat unkeyed number? Even on normal objects you can't use chls to get the values if they aren't keyed.

You can use

opparm -d /obj/myObj myChannel

You'd have to munge the result in order to re-use it on another object.

Or you could try oppresetsave and oppresetload??

It is odd there isn't a slick way to do this, surely in H9 though???

Link to comment
Share on other sites

they are keyframed values.. I want to copy such animated channels to others...

I cant try your suggestions right now not cause I dont have Houdini here (it'll never happens :P).. but just cause I've my fly to get back home in 6 hours.. and I'm too "confused" yet after these two London-days ;)...

I'll give a try when my head will be back to "back to normal life" state ... which I dont think will happens before the weekend...

Link to comment
Share on other sites

Hey Jean-Claude

In the last place I worked I had tools set up that could copy animation channels from themselves on to other objects. It is doable but a major pain in the ass!

I did it using "opscript -g" which I saved to a temporary command file so I could process it. Opscript gives you a complete listing of all of the keyframes, expressions, etc and the -g option "generalises" the name of the operator in the listing to use "$arg1" so that you can then run the command file with the name of a new operator you want to apply the channels to. You need to process the temporary command file to delete the commands you DON'T want to apply; the opparm and opset lines being the main ones (but you may also want to strip out cerain animated parameters). You could run it through awk, perl or python to do the pattern matching.

Not pretty but as I said I used to do just this. You can wrap it all up into a script inside an HDA that creates the temp files, processes them and then cleans up so noboby ever needs to know!

If you really want to desend into this madness and need more help with it give me a shout.

john

Link to comment
Share on other sites

thanks john... count on my shout cause I'll need your help for sure :) .. i guess i'll put my hands on it next week cause tomorrow I'll be back at work after the roadshow (I had my fly this afternoon.. and now I'm back from Ice Hockey... I cant remember last time i was *so* tired) and tomorrow I'll be almost useless except for my boss... which I definetly wanna have some serious talk once per all....

your exaplaination sounds pretty clear to read.. I'll just have to put in action which I'll might get stuck somewhere... I'll use Python btw... oh.. who said I'll now write as much python as I can waiting for version 9?? :D

thanks a lot for your availability on this.. I'll write you next week.

cheers

Link to comment
Share on other sites

  • 2 weeks later...
Happy to help. I'm taking a brief vacation from Wednesday to Sunday next week though so best get any questions to me Monday or Tuesday if you can. I'll see if I can put together an example of the technique I'm describing for you.

Jean-Claude, I'm back from my hols now.

Here is one possible solution for copying animated channel data between objects. This script is assumed to live inside an HDA. Building the awk command within the hscript does make it a bit more tricky to read but I prefer to have everything in one place if at all possible as it makes things more portable. The method used here is to generate a generic opscript file on disk and then filters through awk to extract the lines refering to each parameter that we want to copy animated channels from. The generic opscript file is processed for each parameter in the parmsToCopy list. Hopefully the comments should explain what is going on but ask questions if you get stuck.

Maybe SESI will make this process easier in future versions.

john

set thisObject = `opfullpath(".")`
set destination = "geo1"                          # or pass it in as an argument ($arg1) or read it from an HDA parameter, etc
set parmsToCopy = "tx ty tz rx ry rz sx sy sz"    # .. or whatever!

# Use opscript -g to write out the generic creation script for the current node
opscript -g $thisObject > /tmp/copyGeneric.cmd

foreach parmToCopy ( $parmsToCopy )

   # Look at the data channel to see if it contains the same name as the parameter.
   # If so the channel is animated and we need to process it to save out the keyframes.
   set opparmExpression = `execute("opparm -d $thisObject ${parmToCopy}")`
   set parameter = `arg ($opparmExpression, 4)`
   if ("$parameter" == ${parmToCopy} && "$parameter" != "" )

       # Build an awk command which filters the opscript to keep only those lines containing the
       # current parameter (these are lines that end with the parameter following ' ' or '/' chars).
       # Also, replace the the generic "$arg1" reference with the specific destination object name.
       # ENSURE THE FOLLOWING AWK COMMAND IS ALL ON ONE LINE
       echo "awk '/[\ \/]${parmToCopy}$/ { sub(/"'\$'"arg1/, \"$destination\"); print }' /tmp/copyGeneric.cmd > /tmp/copySpecific.cmd " > /tmp/convert.awk

       # Make the awk command executable and then run it
       echo -n `system("chmod 755 /tmp/convert.awk")`
       echo -n `system("/tmp/convert.awk")`

       # Apply the cleaned up keyframe data to the destination object
       chblockbegin
       source /tmp/copySpecific.cmd
       chblockend

       # Delete temporary files
       echo -n `system("rm -f /tmp/convert.awk")`
       echo -n `system("rm -f /tmp/copySpecific.cmd")`

   else

       # If the channel wasn't animated just copy over the hard-coded value
       opparm /obj/$destination ${parmToCopy} ( `ch("$thisObject/${parmToCopy}")` )

   endif

end

# Delete the generic opscript file
echo -n `system("rm -f /tmp/copyGeneric.cmd")`

Link to comment
Share on other sites

woof... its late night and I'm back from an heavy night... I'l give it a look tomorrow! thanks a lot for your time :)

I'll let you know..

ps. late nights toughts... but... aint CHOP maybe a solution for this, at my eyes, simple problem? cant CHOP copy/plot/paste channels from whatever I want.. to whatever I want?....

Link to comment
Share on other sites

[one' date=Oct 10 2006, 07:45 PM' post='31285]

woof... its late night and I'm back from an heavy night... I'l give it a look tomorrow! thanks a lot for your time :)

I'll let you know..

ps. late nights toughts... but... aint CHOP maybe a solution for this, at my eyes, simple problem? cant CHOP copy/plot/paste channels from whatever I want.. to whatever I want?....

well... going back to your first post in this thread you said you want to copy the animation rather than channel referenced.

The reason we went this route is that we needed a way to copy animations from one asset on to other assets. Our pipeline invovled assets making copies of themselves and the parent asset would automatically configure its children as needed, including copying (and modifying) animated channels from itself on to its children. The animation had to be copied rather than channel referenced so that the assets could be indpendently modified by artists and so we could push the child assets to other shots without the parent asset having to be being present.

Hope that wasn't overkill for what you need. Maybe all you need is channel references or something.

As a side note, I always thought that the idea of assets making copies of themselves and then automatically modifying the animation on their 'children' using asset scripts would be a great way to do some interesting AI effects.

john.

Link to comment
Share on other sites

As a side note, I always thought that the idea of assets making copies of themselves and then automatically modifying the animation on their 'children' using asset scripts would be a great way to do some interesting AI effects.

Or a virus :) ... But that could be a topic for the next 42 contest ... Houdini COREWARs in 42 nodes. :)

Link to comment
Share on other sites

well... going back to your first post in this thread you said you want to copy the animation rather than channel referenced.

The reason we went this route is that we needed a way to copy animations from one asset on to other assets. Our pipeline invloved assets making copies of themselves and the parent asset would automatically configure its children as needed, including copying (and modifying) animated channels from itself on to its children. The animation had to be copied rather than channel referenced so that the assets could be indpendently modified by artists and so we could push the child assets to other shots without the parent asset having to be being present.

Hope that wasn't overkill for what you need. Maybe all you need is channel references or something.

As a side note, I always thought that the idea of assets making copies of themselves and then automatically modifying the animation on their 'children' using asset scripts would be a great way to do some interesting AI effects.

john.

no no.. dont get me wrong.. your advice and script idea is what I was looking for... what i was wondering was just if there were a way to copy/paste/plot channels using CHOPs... the result i need is exactly what you're helping me on .. copy channels from an HDA to another :)

cheers

Link to comment
Share on other sites

  • 4 weeks later...

ok after a while I'm back to this thread... I carefully read all your posts John.. and ... I've got the noobiest question I can ever ask ...

from your reply in post #13 of this thread

Jean-Claude, I'm back from my hols now.

Here is one possible solution for copying animated channel data between objects. This script is assumed to live inside an HDA.

[...]

the question is .... how do I make suck script inside an HDA?...

I mean phisically where i do write such script.... cause until now.. my knoledge permits me to just use the "callback script" which I used with some buttons I created for various options... but I'm sure you didnt ment this... :):) thanks a lot in advance.

just in case i put it in another way ... since I'm almost near to the solution of this thread with only one limit ... I need the HDA to be "editable" cause i need to use the "opcopy" hscript command..

everything works fine for my needs... but is there a way to make it working with a locked HDA?...

cheers

Link to comment
Share on other sites

[one' date=Nov 3 2006, 06:21 PM' post='31758]

ok after a while I'm back to this thread... I carefully read all your posts John.. and ... I've got the noobiest question I can ever ask ...

from your reply in post #13 of this thread

the question is .... how do I make suck script inside an HDA?...

I mean phisically where i do write such script.... cause until now.. my knoledge permits me to just use the "callback script" which I used with some buttons I created for various options... but I'm sure you didnt ment this... :):) thanks a lot in advance.

just in case i put it in another way ... since I'm almost near to the solution of this thread with only one limit ... I need the HDA to be "editable" cause i need to use the "opcopy" hscript command..

everything works fine for my needs... but is there a way to make it working with a locked HDA?...

cheers

Actually using a button to call the script is one way to go. Open up the Operator Type Manager and navigate to your digital asset. Right click on it and select "Edit Contents". You can add all of your scripts in there as 'sections'. You will need to give the new script a section name and then click the "Add empty Section" button to create the placeholder for your script. Then select the script from the section list and edit away. To call the script use the opdef sytnax in your callback script in the button parameter of your Digital Asset. For example, if you named your new section "chcopy" you would enter this into the Callback Script parameter of the button:

opdef:.?chcopy

You can add arguments if you like as well which are accessed in the section scripts as $arg1, $arg2, etc. One other thing to consider is the Events section of the Operator Type Properties where you can enter scripts that are automatically called every time certain actions are performed such changing the name of the asset.

And one more tip make it a habit to NEVER have the type properties and edit contents dialoges open at the same time! It is far too easy to make changes in one that are overwritten by accepting changes in the other if both are open.

Click on the ? in your Operator Type Properties to get (a little) more help.

john.

Link to comment
Share on other sites

One more thing, your section script can examine the parameters of your digital asset using channel references. Use '.' to refer to the calling digital asset. For example: chs("./myparameter")

This is useful if you want to have the user set values on the asset that are picked up by the script. So, for example, you could have parameters for the names of the node you want to copy from and the name of the node you want to copy to. You could have a toggle to "copy all channels" or to select from a user supplied list (using another string parameter), etc.

john.

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