View Full Version : want to put stringArray into a Float varible
pigbelly 07-08-2003, 01:02 PM I'm back!!! :-)))
Well you guessed it, I have yet another problem!!! :-)
I have a string array containing:
0.33434
-1.3455
0.22
I want to force them into a float variable to be able to set the xyz position of an object
/Tommie
|
|
hi,
you can directly cast a string to a float variable:
string $s="-3.14";
float $v=$s;
print($v*5.0);
about your string array:
string $sArray[] = {"-5.0","8.236","41.2"};
float $fArray[];
for ($i=0; $i<size($sArray); $i++)
{
$fArray[$i]=$sArray[$i];
}
klod
mark_wilkins
07-08-2003, 07:21 PM
Maybe I'm missing something. You can just use the string variables with the move or setAttr commands, or you can assign them to a float attribute if you're in an expression:
here's an example with the move command:
string $sArray[] = {"-5.0","8.236","41.2"};
string $theSphere[] = `sphere -name mySphere`;
move -ws $sArray[0] $sArray[1] $sArray[2] $theSphere[0];
and here's an expression:
string $test = "54.2";
ty = $test;
Maya will cast the types for you automatically.
-- Mark
I didn't knew it; that's cool !
thanks Mark ;)
CGTalk Moderation
01-15-2006, 02:00 PM
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.