Quantcast
Channel: mel wiki
Viewing all articles
Browse latest Browse all 610

How can I query the enumNames for an enumAttr?

$
0
0
You don't want to query the current enumAttr value, you want to query all their names:

string $enumAttrs = `addAttr -q -enumName "myNode.myEnumAttr"`;
This returns a single string of attr names separated by colons:
"enumA:enumB:enumEct"

Tip from my buddy Te:
string $enumAttrs[] = `attributeQuery -node "myNode" -listEnum "myEnumAttr"`;
This returns an array, with a single string value separated by colons:
{"enumA:enumB:enumEct"}

Or, via PyMel's Attribute.getEnums() method:
(Modified example from the PyMel docs):
>>> from pymel.core.general import Attribute
>>> addAttr( "persp", ln='numbers', at='enum', enumName="zero:one:two:thousand=1000:three")
>>> numbers = Attribute('persp.numbers').getEnums()
>>> sorted(numbers.items())
[(u'one', 1), (u'thousand', 1000), (u'three', 1001), (u'two', 2), (u'zero', 0)]
>>> numbers[1]
u'one'
>>> numbers['thousand']
1000
Note, PyMel will raise a TypeError of the enum has no values.

Viewing all articles
Browse latest Browse all 610

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>