pymel.core.general.attributeQuery

attributeQuery(*args, **kwargs)

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.)

Flags:
Long name (short name) Argument Types Properties
affectsAppearance (aa) bool ../../../_images/create.gif
 
Return true if the attribute affects the appearance of the node
affectsWorldspace (aws) bool ../../../_images/create.gif
 
Return the status of the attribute flag marking attributes affecting worldspace
attributeType (at) bool ../../../_images/create.gif
 
Return the name of the attribute type (will be the same type names as described in the addAttr and addExtension commands).
cachedInternally (ci) bool ../../../_images/create.gif
 
Return whether the attribute is cached within the node as well as in the datablock
categories (ct) bool ../../../_images/create.gif
 
Return the categories to which the attribute belongs or an empty list if it does not belong to any.
channelBox (ch) bool ../../../_images/create.gif
 
Return whether the attribute should show up in the channelBox or not
connectable (c) bool ../../../_images/create.gif
 
Return the connectable status of the attribute
enum (e) bool ../../../_images/create.gif
 
Return true if the attribute is a enum attribute
exists (ex) bool ../../../_images/create.gif
 
Return true if the attribute exists
hidden (h) bool ../../../_images/create.gif
 
Return the hidden status of the attribute
indeterminant (idt) bool ../../../_images/create.gif
 
Return true if this attribute might be used in evaluation but it’s not known for sure until evaluation time
indexMatters (im) bool ../../../_images/create.gif
 
Return the indexMatters status of the attribute
internal (i) bool ../../../_images/create.gif
 
Return true if the attribute is either internalSet or internalGet
internalGet (ig) bool ../../../_images/create.gif
 
Return true if the attribute come from getCachedValue
internalSet (internalSet) bool ../../../_images/create.gif
 
Return true if the attribute must be set through setCachedValue
keyable (k) bool ../../../_images/create.gif
 
Return the keyable status of the attribute
listChildren (lc) bool ../../../_images/create.gif
 
Return the list of children attributes of the given attribute.
listDefault (ld) bool ../../../_images/create.gif
 
Return the default values of numeric and compound numeric attributes.
listEnum (le) bool ../../../_images/create.gif
 
Return the list of enum strings for the given attribute.
listParent (lp) bool ../../../_images/create.gif
 
Return the parent of the given attribute.
listSiblings (ls) bool ../../../_images/create.gif
 
Return the list of sibling attributes of the given attribute.
longName (ln) bool ../../../_images/create.gif
 
Return the long name of the attribute.
maxExists (mxe) bool ../../../_images/create.gif
 
Return true if the attribute has a hard maximum. A min does not have to be present.
maximum (max) bool ../../../_images/create.gif
 
Return the hard maximum of the attribute’s value
message (msg) bool ../../../_images/create.gif
 
Return true if the attribute is a message attribute
minExists (mne) bool ../../../_images/create.gif
 
Return true if the attribute has a hard minimum. A max does not have to be present.
minimum (min) bool ../../../_images/create.gif
 
Return the hard minimum of the attribute’s value
multi (m) bool ../../../_images/create.gif
 
Return true if the attribute is a multi-attribute
niceName (nn) bool ../../../_images/create.gif
 
Return the nice name (or “UI name”) of the attribute.
node (n) PyNode ../../../_images/create.gif
 
Use all attributes from node named NAME
numberOfChildren (nc) bool ../../../_images/create.gif
 
Return the number of children the attribute has
range (r) bool ../../../_images/create.gif
 
Return the hard range of the attribute’s value
rangeExists (re) bool ../../../_images/create.gif
 
Return true if the attribute has a hard range. Both min and max must be present.
readable (rd) bool ../../../_images/create.gif
 
Return the readable status of the attribute
renderSource (rs) bool ../../../_images/create.gif
 
Return whether this attribute is marked as a render source or not
shortName (sn) bool ../../../_images/create.gif
 
Return the short name of the attribute.
softMax (smx) bool ../../../_images/create.gif
 
Return the soft max (slider range) of the attribute’s value
softMaxExists (sxe) bool ../../../_images/create.gif
 
Return true if the attribute has a soft maximum. A min does not have to be present.
softMin (smn) bool ../../../_images/create.gif
 
Return the soft min (slider range) of the attribute’s value
softMinExists (sme) bool ../../../_images/create.gif
 
Return true if the attribute has a soft minimum. A max does not have to be present.
softRange (s) bool ../../../_images/create.gif
 
Return the soft range (slider range) of the attribute’s value
softRangeExists (se) bool ../../../_images/create.gif
 
Return true if the attribute has a soft range. Both min and max must be present.
storable (st) bool ../../../_images/create.gif
 
Return true if the attribute is storable
type (typ) unicode ../../../_images/create.gif
 
Use static attributes from nodes of type TYPE. Includes attributes inherited from parent class nodes.
typeExact (tex) unicode ../../../_images/create.gif
 
Use static attributes only from nodes of type TYPE. Does not included inherited attributes.
usedAsColor (uac) bool ../../../_images/create.gif
 
Return true if the attribute should bring up a color picker
usedAsFilename (uaf) bool ../../../_images/create.gif
 
Return true if the attribute should bring up a file browser
usesMultiBuilder (umb) bool ../../../_images/create.gif
 
Return true if the attribute is a multi-attribute and it uses the multi-builder to handle its data
worldspace (ws) bool ../../../_images/create.gif
 
Return the status of the attribute flag marking worldspace attribute
writable (w) bool ../../../_images/create.gif
 
Return the writable status of the attributeFlag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

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']

Previous topic

pymel.core.general.attributeName

Next topic

pymel.core.general.bakePartialHistory

Core

Core Modules

Other Modules

This Page