kmp3d
12-30-2003, 01:08 AM
I'm trying to figure out to add an animation expression to the attribute of an object through a script... let me show you what I have so I can better explain my problem. This just a simple example to explain what I want to acheive. This script creates 3 locators and adds an expression to one that will cause it maintain a center point between the other two locators just on the X axis. As you can see the name I'm casting into the script is "bob". So it creates the locators adding "bob" to the name of the locators. Now the animation expression works at this point because I used the string "bob" but what if I use "carl"?... the animation expression no longer works because its looking for the string
"bob". So my question is how can I cast any string I want into the procedure and the animation expression will accept it. I'd imagine that there are many times when you want to add animation expressions to a lot of different objects.... but it shouldn't be necessary to alter your code for the name of every different object. Thanks for any help.
scripter "bob";
global proc scripter (string $name)
{
spaceLocator -p 0 0 0 -n ($name + "_locator");
spaceLocator -p 0 0 0 -n ($name + "_locator2");
move -r -os -wd 10 0 0 ;
spaceLocator -p 0 0 0 -n ($name + "_middle");
move -r -os -wd 5 0 0 ;
select -d;
//the exprression that only likes "bob"
expression -s "bob_middle.translateX =(abs (bob_locator.translateX - bob_locator2.translateX)) /2;"
-o bob_middle -ae 1 -uc all ;
}
"bob". So my question is how can I cast any string I want into the procedure and the animation expression will accept it. I'd imagine that there are many times when you want to add animation expressions to a lot of different objects.... but it shouldn't be necessary to alter your code for the name of every different object. Thanks for any help.
scripter "bob";
global proc scripter (string $name)
{
spaceLocator -p 0 0 0 -n ($name + "_locator");
spaceLocator -p 0 0 0 -n ($name + "_locator2");
move -r -os -wd 10 0 0 ;
spaceLocator -p 0 0 0 -n ($name + "_middle");
move -r -os -wd 5 0 0 ;
select -d;
//the exprression that only likes "bob"
expression -s "bob_middle.translateX =(abs (bob_locator.translateX - bob_locator2.translateX)) /2;"
-o bob_middle -ae 1 -uc all ;
}
