The isDirtycommand is used to check if a plug is dirty. The return value is 0 if it is not and 1 if it is. If more than one plug is specified then the result is the logical orof all objects (ie. returns 1 if *any* of the plugs are dirty).
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
connection (c) | bool | ||
|
|||
datablock (d) | bool | ||
|
Derived from mel command maya.cmds.isDirty
Example:
import pymel.core as pm
# Create a plusMinusAverage node and a transform. We set the 'skipSelect'
# flag so that they are not displayed in the Attribute Editor because
# that would force an evaluation and cause the plugs to become clean.
import maya.cmds as cmds
pm.createNode('plusMinusAverage', n='pma', skipSelect=True)
# Result: nt.PlusMinusAverage(u'pma') #
pm.createNode('transform', n='t', skipSelect=True)
# Result: nt.Transform(u't') #
# Hide the transform so that Maya's draw won't force an evaluation which
# would clean its plugs.
pm.hide('t')
# Connect the transform's 'tx' to one of the plusMinusAverage node's
# inputs.
pm.connectAttr('t.tx', 'pma.input1D[0]')
# Set the value of the transform's 'tx' and check that the
# target of the connection has become dirty.
pm.setAttr('t.tx', 13)
pm.isDirty('pma.input1D[0]')
# Result: True #
# If we retrieve the value of the destination attribute
# then the connection becomes clean.
pm.getAttr('pma.input1D[0]')
# Result: 13.0 #
pm.isDirty('pma.input1D[0]')
# Result: False #
# A plusMinusAverage node's 'output1D' attribute depends
# upon the values in its 'input1D' array. Since we haven't
# retrieved its value yet, it should still be dirty. However,
# it seems to be clean:
pm.isDirty('pma.output1D')
# Result: False #
# The reason for this is that the 'isDirty' command
# by default only checks connections and 'output1D' has
# no connection to be dirty. If we instead check its
# value in the datablock, we get the expected result:
pm.isDirty('pma.output1D', d=True)
# Result: True #
# The output value will remain dirty until we
# force its evaluation by retrieving it.
pm.getAttr('pma.output1D')
# Result: 13.0 #
pm.isDirty('pma.output1D', d=True)
# Result: False #