View Full Version : Evaluate attributes in strings
Jakobud 09-23-2003, 07:13 PM If I have this:
string $str = "ball.tx + 1";
and I know that the Translate X value for my ball is 5, how do I take this string and have it evaluated as its true value, which would be 5 + 1 = 6?
I tried this:
$str = `getAttr ball.tx` + 1;
eval $str;
but this doesnt work. Got any ideas?
|
|
dwalden74
09-23-2003, 07:39 PM
float $flt = `getAttr ball.tx` + 1;
:beer:
David
Jakobud
09-23-2003, 11:39 PM
Well that doesnt really help me. I need it to initially be a string because it is going to be something that a user is going to input via a gui. I needed to figure out how to convert the string to a float value. I figured it out. I had the syntax correct but I just didnt need to eval it. Thanks
This works:
string $str = `getAttr ball.tx` + 1;
print $str;
or this:
string $str = `getAttr ball.tx` + 1;
float $num = $str;
print $num;
zachgrachan
09-24-2003, 06:26 PM
you could also use a float field instead of a text field in the GUI.
CGTalk Moderation
01-16-2006, 05: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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.