PDA

View Full Version : expression problem


cyruslam
10-09-2010, 05:51 PM
hello all i have fcae toe some problem
now i my scene have 3 joint and i have created a tool to auto create expression to the joint

normally i can create a expression in expression editor like this:


$scale = ytsk_curveInfo.arcLength /1.2
joint.scaleX =$scale


but now i want to create all the expression automatically for all the joint i selected


global proc creatSAndS ()

string $sAsHier[] = `ls -sl`;
float $cureInfo = `arclen ytsk_IKCurve`;

for ($eachSASSel in $sAsHier)
{
string $allSelX = ($eachSASSel+".scaleX\n");
print $allSelX;
string $curveInfoNode = `arclen -ch on ytsk_IKCurve`;
expression -s "$scale = ytsk_curveInfo.arcLength /$cureInfo; $eachSASSel = $scale;" -o $eachSASSel -ae 1 -uc all;


}

this script run no error but the expression didnt add to their scaleX
so i dont know what happen
please help
thanks

Windows90
10-10-2010, 01:26 AM
Hey,
expression -s "$scale = ytsk_curveInfo.arcLength /$cureInfo; $eachSASSel = $scale;" -o $eachSASSel -ae 1 -uc all;

You put the string "$eachSASSel" directly into expression instead of its value, I think this' the problem.

You can replace it with
expression -s "$scale = ytsk_curveInfo.arcLength /$cureInfo; "+$eachSASSel+" = $scale;" -o $eachSASSel -ae 1 -uc all;

cyruslam
10-10-2010, 11:37 AM
hello
i have used your script but it gave me a error

for ($eachSASSel in $sAsHier) {
string $allSelX = ($eachSASSel+".scaleX\n");
print $allSelX;
string $curveInfoNode = `arclen -ch on ytsk_IKCurve`; expression -s "$scale = ytsk_curveInfo.arcLength /$cureInfo; "+$eachSASSel+" = $scale;" -o $eachSASSel -ae 1 -uc all; }


// Error: expression -s "$scale = ytsk_curveInfo.arcLength /$cureInfo; "+$eachSASSel+" = $scale;" -o $eachSASSel -ae 1 -uc all;
//
// Error: Syntax error //

Windows90
10-11-2010, 01:56 AM
Sorry for my hasty reply, the string expression should be put into brackets.

expression -s ("$scale = ytsk_curveInfo.arcLength /$cureInfo; "+$allSelX+" = $scale;") -o $eachSASSel -ae 1 -uc all;
//$eachSASSel is a object name, you couldn't make a object and a float value equal
//I think you mean $allSelX

And if you want get the length of ytsk_IKCurve, your should substitute the ytsk_curveInfo using $curveInfoNode in the same way. That's a problem, but maybe not the problem.

If you are a mel beginner I recommend you read some reference first. "Mo dao bu wu kan chai gong" anyway.

cyruslam
10-11-2010, 03:28 AM
hey, thank you very much, sorry i'm very beginner in mel (even programming)
by the way i dont really know how to use and when i need to use some syntax like "+" " () " {}" even you show me the script "+$allSelX+" i dont know why we need to use "+

do you have some referenece of it? because i have checked in Here (http://download.autodesk.com/us/maya/2009help/Commands/index.html) but cant find any information for me.

thanks

Windows90
10-11-2010, 04:25 AM
Have a look at MEL and Expressions (http://download.autodesk.com/us/maya/2009help/index.html?url=WS73099cc142f48755-4bc38c931187aa80bc9-32a7.htm,topicNumber=d0e152391) .

And there's a great book called Maya Complete Programming. It could help you a lot.

Jiayou~ bro :D

cyruslam
10-11-2010, 04:44 AM
thank you very much~bro~
checking the website now.

(and i like your chinese :thumbsup: 謝謝!)

CGTalk Moderation
10-11-2010, 04:44 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.