$Strings[0] in expressions

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2010   #1
$Strings[0] in expressions

So I'm trying to use a string in an expression although I'm not having any luck. There is something in the help for expressions that says you need an escape \" for quotes or it'll get confused, well that's just down right confusing me. Maybe there is a better way to go about this, I read somewhere that I could write a script that writes an expression??? sounds wild to me. Anyways here's what I have.

expression -s "polyExtrudeFace1.localTranslateZ = WheelMeasuringDevice69.SideWallHeight * (.01) * polyCylinder1.height" -o $wmd[1] -ae 1 -uc all ; // this works but only for objects named exactly that.

expression -s "($sw[0] + ".localTranslateZ") = 0.01* ($wmd[0] + ".SideWallHeight") * .01 * ($wmd[1] + ".height")" -o $wmd[1] -ae 1 -uc all ; // This is how I expected it to work.

expression -s "$swhLTZ = $wmdSWH * (.01) * $wmdSWH" -o $wmd[1] -ae 1 -uc all ; // yells at me for putting something in an expression ???

well if anyone has suggestions or need more info let me know.
 
Old 06 June 2010   #2
it can be done it can just be annoying at times.

so lets say we have 3 cubes and we want to make an expression similar to yours on them:

string $s[] = `ls -sl`; //Get the selection

//Add your attributes
addAttr -ln "localTranslateX" -at double  -dv 0 $s[0];
setAttr -e-keyable true  ($s[0] + ".localTranslateX");
addAttr -ln "sideWallHeight" -at double  -dv 0 $s[1];
setAttr -e-keyable true  ($s[1] + ".sideWallHeight");
addAttr -ln "height" -at double  -dv 0 $s[2];
setAttr -e-keyable true  ($s[2] + ".height");

//Now lets make the expression
string $expString = $s[0] + ".localTranslateX = 0.01 * " + $s[1] + ".sideWallHeight *  0.01 * " + $s[2] + ".height;";
print $expString;
expression -s $expString -o $s[2] -ae 1 -uc all ;


i hope this helps
__________________
http://www.jacobschieck.com
 
Old 06 June 2010   #3
Worked perfectly! Thank you!

I replaced my strings where you had yours and it works great. If your up to it could you explain why the " and + go where you have them in the string? with the setAttr it makes sense with the ( and all but in the string it kind of blows my mind and I can't see the method. I'm sure if I look at it long enough and play with it more I'll figure out why it works.

Thanks again!

oh if your interested in a script thingy that makes a tire measuring device lemme know and I'll post it up.
 
Old 06 June 2010   #4
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:04 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.