|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| A way to store coordinates?
|
|
|
Hey everyone!
I would like to know how to store coordinates in a variable/array so that I can use these coords while creating an object.
This was my first attempt (Im new to mel, and scripting in general :P) which didn’t work because Im using a string instead of an integer. But so far I havent found a fix.
string $locName[]= {"thigh01", "knee01", "ankle01", "ball01", "toes01", "heel01"};
string $locPos[]= {"0 6 0","0 3 1","0 1 0","0 0 1","0 0 2","0 0 -1" };
int $arraySize = size($locName);
for ($counter=1; $counter <= $arraySize; $counter++)
{
spaceLocator -name $locName[$counter] -p $locPos[$counter];
CenterPivot;
}
I tried googling for an array that stores coords but without any luck.
My next idea would have been to store Vectors in an array and somwhow reading out their coords to use as the coords for the locator I want to place.
Is that going the right direction?
Appreciate the help :)
Cheers!
J.D.
AutoWalk script out on CreativeCrash!
http://www.creativecrash.com/may...gins/animation/c/autowalk
Jeeves Simple Biped Rig:
http://www.creativecrash.com/maya/downloads/character-rigs/c/jeeves
Dload, test & share! Feedback very much appreciated!
|
|
|
|
example:
vector $va[] = {<<1.0, 2.0, 3.0>>,<<2.0, 4.0, 6.0>>};
|
|
|
|
Well, that was simple. :D thx!
However I get another error now <.<
Error:Error While parsing arguments
Can’t use the vector Array like this, I guess?
**edit** And if someone could explain the Error to me so I’ll know what to look for, that would be kewl, too :) thx!
global proc createLocs () {
//Define variables used to name locators
string $locName[]= {"thigh01", "knee01", "ankle01", "ball01", "toes01", "heel01"};
vector $va[] = {<<0,6,0>>,<<0,3,1>>,<<0,1,0>>,<<0,0,1>>,<<0,0,2>>,<<0,0,-1>>};
int $arraySize = size($locName);
for ($counter=1; $counter <= $arraySize; $counter++)
{
//Create Locator named accordningly to the name stored in the Array
spaceLocator -name ($locName[$counter]) -p $va[$counter];
select ($locName[$counter]);
CenterPivot;
}
}
AutoWalk script out on CreativeCrash!
http://www.creativecrash.com/may...gins/animation/c/autowalk
Jeeves Simple Biped Rig:
http://www.creativecrash.com/maya/downloads/character-rigs/c/jeeves
Dload, test & share! Feedback very much appreciated!
|
|
|
|
I believe it’s because the -p flag for spaceLocator is expecting 3 linear units, not one vector, or something to that effect. For the first line of your loop you can just recast the vector as a float array, then use that for the -p flag. Also, your initialization counter needs to start at 0, since the arrays are all a zero based index. And the condition needs to be just < not <=, since if it’s equal it will run one more time than you want and you’ll end up with an extra locator.
//Define variables used to name locators
string $locName[]= {"thigh01", "knee01", "ankle01", "ball01", "toes01", "heel01"}; vector $va[] = {<<0,6,0>>, <<0,3,1>>, <<0,1,0>>, <<0,0,1>>, <<0,0,2>>, <<0,0,-1>>}; int $arraySize = size($locName);
for ($counter=0; $counter < $arraySize; $counter++) { //Create Locator named accordningly to the name stored in the Array float $lin[] = $va[$counter]; spaceLocator -name $locName[$counter] -p $lin[0] $lin[1] $lin[2]; select $locName[$counter]; CenterPivot; }
|
|
|
|
Aaah..*zing*! :D
Hokai, that makes perfect sense :D
And works perfectly now.
Thanks! :D
JD
AutoWalk script out on CreativeCrash!
http://www.creativecrash.com/may...gins/animation/c/autowalk
Jeeves Simple Biped Rig:
http://www.creativecrash.com/maya/downloads/character-rigs/c/jeeves
Dload, test & share! Feedback very much appreciated!
|
|
|
|