PDA

View Full Version : how to query no. of possible entries of enum attribute?


ManuelM
06-02-2006, 11:48 AM
lets say i have a sphere with an extra attribyte of type "enum" ...

sphere -n mySphere;
addAttr -ln colors -at "enum" -en "Green:Blue:Red:Black:White" mySphere;
setAttr -e -keyable true mySphere.colors;


how can i query, the total number of possible values of mySphere.colors

hope i made myself clear. i want maya to return "5", as thats the no. of colors to choose from in my example.

many thanks for your help in advance!

AyaKoshigaya
06-02-2006, 02:26 PM
Hi,

you can -query the addAttr Command to retrieve the -max value for the Count and the -en value for the name-string.

proc printEnums(string $nodeAttr) {
string $enums[];
string $attr = `addAttr -q -en $nodeAttr`;
tokenize $attr ":" $enums;
print ("EnumCount: " + (`addAttr -q -max $nodeAttr` + 1) + "\n");
print "EnumNames: ";
for ($i = 0; $i < size($enums) - 1; $i++)
print ($enums[$i] + ", ");
print ($enums[`size($enums)` - 1] + "\n");
} printEnums("mySphere.colors");
Aya~

CGTalk Moderation
06-02-2006, 02:26 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.