PDA

View Full Version : get attribute


fbitonti
05-16-2005, 03:30 AM
I'm trying to write a script where I need to be able to be able to allow the script to get data about the x axis position of an object and store the data in a variable. What is the command to get call this data. I realize that The object must be given a paritcular name in this case the object I need to obtain data from is called "disk1." Thanks every one for your help.

twidup
05-16-2005, 03:36 AM
getAttr is the command

the variable would depend... a float woudl be like this :

float $curX = `getAttr "disk1.tx"`;

fbitonti
05-17-2005, 05:11 AM
Thank you for the responce but can some one give me a working example of how this is used. I looked up the function in the documentation and am a bit confused. All i'm interested in is obtaining the position data but I don't see how to do that from the documentaion. I'm new to this so I need a littel more information. Thanks for the help.

drGonzo
05-17-2005, 06:00 AM
//create a sphere and move it
polySphere;
move -r -ls -wd 5.50863 0 0 ;

//put translate X in a variable called $xPos
float $xPos = `getAttr pSphere1.tx`;

fbitonti
05-17-2005, 03:57 PM
Hey guys thanks for the help I think i understand now. The ".tx" which calls up the attribute for the x position where can i get a list of these extensions and the attributes they stand for. Thank you very much for your help.

twidup
05-17-2005, 06:00 PM
yeah

t is for translate, r : rotate, s : scale

usually the name in teh channel box works, usually just eneds a lowercase for the first letter

like Translate X is translateX

As for finding out what teh various one are...not sure of anyplace that actually lists them. You also have to remember, you can create new attributes as well, so teh list would never be totally accurate.

the 4 basics are t, r, s, v (visibility)

t/r/s have either xyz as teh end as well, otherwise it will return all three floats into an array....just something to be aware of.

-todd

mhovland
05-17-2005, 10:43 PM
You can type:

listAttr <OBJECT>;

to get a list of all the object in questions attributes. Wh I need to do that I throw the result of listAttr in an array, sort the array and then print the array, so things are a little easier to track down and read in the script editor.

NolanSW
05-18-2005, 06:36 PM
I think the xform command is a bit better for the retrieving the position since you can query the World space.
Example

polyCube;
move -r -ls -wd 0 0 6.220843 ;
float $worldPosition[] = `xform -q -ws -translation`;

//show world X pos
print ($worldPosition[0] + "\n");
//show world Y pos
print ($worldPosition[1] + "\n");
//show world Z pos
print ($worldPosition[2] + "\n");
//Result:
0
0
6.220843312


Sean

fbitonti
05-19-2005, 02:58 AM
Thanks for your help i'm realy getting the hang of this stuff...

My last question for this thread is there any way to porform logorithmic and exponential functions in mel?

drGonzo
05-19-2005, 03:12 AM
http://localhost:4446/Maya6.0/en_US/Commands/

> MATH

fbitonti
05-19-2005, 01:42 PM
I can't seem to get that link to work.

drGonzo
05-21-2005, 01:45 PM
Ah.
Just go to your MEL command reference. On the top there is a math category.

CGTalk Moderation
05-21-2005, 01:45 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.