Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / A way to store coordinates?
  RSS 2.0 ATOM  

A way to store coordinates?
Rate this thread
 
56231
 
Permlink of this thread  
avatar
  • J.D.
  • Posted: 25 May 2011 11:49 AM
  • Location: Berlin
  • Total Posts: 65
  • Joined: 17 November 2010 04:53 AM

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!

Replies: 0
avatar
  • THNKR
  • Posted: 25 May 2011 03:54 PM

example:

vector $va[] {<<1.02.03.0>>,<<2.04.06.0>>};


Replies: 0
avatar
  • J.D.
  • Posted: 25 May 2011 09:34 PM

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!

Replies: 0
avatar

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;
}


Replies: 0
avatar
  • J.D.
  • Posted: 26 May 2011 08:20 PM

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!

Replies: 0