PDA

View Full Version : expression creation via script ?


ferdo
04-24-2004, 07:56 PM
hi there !

first of all, i am completly new to mel.

well what i want to do :
create a mel script for changing translationlimits
a locator is geometry constrained on a floor and parentet to a foot of a character
the character foot gets the limit for translateY from the locator so that it cant get under the floor.


this is my expression to do that :

float $min = locator1.translateY;
transformLimits -ty $min 1 -ety 1 0 nurbsSphere1;


next i want to make a script :

i select the locator, then the foot, and want to execute the melscript for creating this expression


i got this far :

string $nodes[];
$nodes = `selectedNodes`;
select -cl;
expression -o "$nodes[0]" -s "float $min = `getAttr($nodes[0]+".translateY")`;transformLimits -ty $min 1 -ety 1 0 $nodes[1];";

and got this errors:
// Error: No object matches name: .translateY //
// Error: Unable to parse command argument list. //


can you please tell me where the problem is ?
thx a lot
Ferdo

galactor
04-24-2004, 08:43 PM
Looks like, in this case your array $nodes is empty. I think this because maya sees .translateY as an object while it suposed to be an atribute.
You can varify the existence of the attribute before creating the script, and also make sure the array is not empty.

:: Galactor ::

ferdo
04-24-2004, 09:29 PM
well, just checked it with the print command
and the list remain stored in $nodes

so thats not the problem

ferdo
04-25-2004, 01:40 AM
hi again !

i tried it again
first it worked, dont know how
now it doesnt work anymore
now my script looks like this :

string $nodes[];
$nodes = `selectedNodes`;

string $exp1 = "float $min = `getAttr($nodes[0]\".translateY\")`; \r\n";
string $exp2 = "transformLimits -ty $min 1 -ety 1 0 $nodes[1];";
string $expr = $exp1 + $exp2;

expression -s $expr -o $nodes[1] -ae 1 -uc all ;

i found one problem from the 1st script : to get a " into a string i had to write \"

well but now i have another problem

// Error: {float $min = `getAttr($nodes[0]".translateY")`;
//
// Error: Line 1.45: Syntax error //

brubin
04-26-2004, 02:32 PM
you're missing a "+"-sign in your statement. composed strings are like ($node[0]+".ty")

HIH
s.

ferdo
04-26-2004, 05:32 PM
wow !

thx a lot !!!

i really wasn't able to find that error !
now it works fine !!!

with best regards
Ferdo

CGTalk Moderation
01-18-2006, 02:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.