attributeQuery returns information about the configuration of an attribute. It handles both boolean flags, returning true or false, as well as other return values. Specifying more than one boolean flag will return the logical “and” of all the specified boolean flags. You may not specify any two flags when both do not provide a boolean return type. (eg. “-internal -hidden” is okay but “-range -hidden” or “-range -softRange” is not.)
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
affectsAppearance (aa) | bool | ||
|
|||
affectsWorldspace (aws) | bool | ||
|
|||
attributeType (at) | bool | ||
|
|||
cachedInternally (ci) | bool | ||
|
|||
categories (ct) | bool | ||
|
|||
channelBox (ch) | bool | ||
|
|||
connectable (c) | bool | ||
|
|||
enum (e) | bool | ||
|
|||
exists (ex) | bool | ||
|
|||
hidden (h) | bool | ||
|
|||
indeterminant (idt) | bool | ||
|
|||
indexMatters (im) | bool | ||
|
|||
internal (i) | bool | ||
|
|||
internalGet (ig) | bool | ||
|
|||
internalSet (internalSet) | bool | ||
|
|||
keyable (k) | bool | ||
|
|||
listChildren (lc) | bool | ||
|
|||
listDefault (ld) | bool | ||
|
|||
listEnum (le) | bool | ||
|
|||
listParent (lp) | bool | ||
|
|||
listSiblings (ls) | bool | ||
|
|||
longName (ln) | bool | ||
|
|||
maxExists (mxe) | bool | ||
|
|||
maximum (max) | bool | ||
|
|||
message (msg) | bool | ||
|
|||
minExists (mne) | bool | ||
|
|||
minimum (min) | bool | ||
|
|||
multi (m) | bool | ||
|
|||
niceName (nn) | bool | ||
|
|||
node (n) | PyNode | ||
|
|||
numberOfChildren (nc) | bool | ||
|
|||
range (r) | bool | ||
|
|||
rangeExists (re) | bool | ||
|
|||
readable (rd) | bool | ||
|
|||
renderSource (rs) | bool | ||
|
|||
shortName (sn) | bool | ||
|
|||
softMax (smx) | bool | ||
|
|||
softMaxExists (sxe) | bool | ||
|
|||
softMin (smn) | bool | ||
|
|||
softMinExists (sme) | bool | ||
|
|||
softRange (s) | bool | ||
|
|||
softRangeExists (se) | bool | ||
|
|||
storable (st) | bool | ||
|
|||
type (typ) | unicode | ||
|
|||
typeExact (tex) | unicode | ||
|
|||
usedAsColor (uac) | bool | ||
|
|||
usedAsFilename (uaf) | bool | ||
|
|||
usesMultiBuilder (umb) | bool | ||
|
|||
worldspace (ws) | bool | ||
|
|||
writable (w) | bool | ||
|
Derived from mel command maya.cmds.attributeQuery
Example:
import pymel.core as pm
import maya.cmds as cmds
# Determine the hidden status of the "selector" attribute on choice nodes.
#
pm.attributeQuery( 'selector', typ='choice', h=True )
# Result: False #
# Result: 0
# Determine the hidden status of the "selector" attribute on this choice node.
# (Usually the same but you can do this for dynamic attributes too.)
#
pm.createNode( 'choice', n='whoIsIt' )
# Result: nt.Choice(u'whoIsIt') #
# Result: choice1
pm.attributeQuery( 'selector', n='whoIsIt', h=True )
# Result: False #
# Result: 0
# Determine the range of the selector value on choice nodes.
# In this case there is no range.
# Note, if there is only a minimum or only a maximum range will not set.
#
pm.attributeQuery( 'selector', typ='choice', range=True )
# For the next several examples create a poly cube and add extra attributes.
pm.polyCube( cuv=4, ch=1, w=1, h=1, d=1, sx=1, sy=1, sz=1, ax=(0, 1, 0) )
pm.addAttr( '|pCube1', ln='egRange', at='long', min=0, max=5, dv=2 )
pm.setAttr( '|pCube1.egRange', e=True, keyable=False )
# Determine if an attribute is keyable
#
pm.attributeQuery( 'egRange', node='pCube1', k=True )
# Result: 0
# Determine the minimum and maximum values of the added attribute egRange
#
pm.attributeQuery( 'egRange', node='pCube1', range=True )
# Result: [0.0, 5.0]
# Determine if there is a minimum for the attribute.
# Note, having a minimum or maximum value does not imply the attribute has a range.
pm.addAttr( '|pCube1', ln='egMin', at='long', min=2 )
pm.attributeQuery( 'egMin', node='pCube1', minExists=True )
# Result: 1
pm.attributeQuery( 'egMin', node='pCube1', maxExists=True )
# Result: 0
pm.attributeQuery( 'egMin', node='pCube1', min=True )
# Result: [2.0]
# Determine if an attribute is an enum
# List the enum strings. This will use ':' as a separator like the attr is written in
# an .ma file.
pm.addAttr( '|pCube1', ln='myEnum', at='enum', en='chicken:turkey:duck:', ct='fowl' )
pm.attributeQuery( 'myEnum', node='pCube1', listEnum=True )
[u'chicken:turkey:duck']
# Secondary way to find an attribute's type directly
pm.attributeQuery( 'myEnum', node='pCube1', attributeType=True )
['enum']
# See to which categories and attribute belongs
pm.attributeQuery( 'myEnum', node='pCube1', categories=True )
['fowl']