Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 19-09-2005 , 07:12 PM
mayakid14's Avatar
Registered User
Join Date: Nov 2004
Location: Florida
Posts: 105

Query an objects attribute

Lets say you created an float variable

float $testvar;

then say you create a polygon cube in your scene.

polyCube;
//Result: pCube1

then you wanted to query the value of pCube1's translateY and assign it to the $testvar float attribute.

how do you query the value of a transform's attribute.
like pCube1.ty?

I have been in situations where i had to query the value of other things like UI elements but UI elements like windows already have a flag for querying.

Ex. maybe you ran into one of these before

if((`window -q -exists testwindow`)==true) deleteUI testwindow;

well is there some kind of query flag for transforms also?


I hope you didn't waste your time reading this line.
# 2 20-09-2005 , 08:54 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
it's an attribute so you need to use the getAttr command:

float $ty = `getAttr pCube1.ty`;

that will do it.

to set it use the setAttr command

setAttr pCube1.ty 10;



user added image
A


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 3 20-09-2005 , 12:52 PM
mayakid14's Avatar
Registered User
Join Date: Nov 2004
Location: Florida
Posts: 105
:headbang: Dummy....how could i have not fingured that out ....

Thanks you've been a big help.user added image


I hope you didn't waste your time reading this line.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads