Go to: Synopsis. Return value. Flags. Python examples.
condition(
string
, [delete=boolean], [dependency=string], [initialize=boolean], [script=string], [state=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
condition is undoable, queryable, and editable.
This command creates a new named condition object whose true/false value is calculated by running a mel script. This new condition can then be used for dimming, or controlling other scripts, or whatever.
None
In query mode, return type is based on queried flag.
| Long name (short name) | Argument types | Properties | ||
|---|---|---|---|---|
delete(delete)
|
boolean
|
|
||
|
||||
dependency(d)
|
string
|
|
||
|
||||
initialize(i)
|
boolean
|
|
||
|
||||
script(s)
|
string
|
|
||
|
||||
state(st)
|
boolean
|
|
||
|
||||
import maya.cmds as cmds
# Create a new condition, called "UndoNorRedo", which is true if
# and only if undo is not available and redo is not available:
def isUndoNorRedo() :
return not cmds.isTrue('UndoAvailable') and not cmds.isTrue('RedoAvailable')
cmds.condition('UndoNorRedo', initialize=True, d=['UndoAvailable', 'RedoAvailable'], s='isUndoNorRedo')
# Try out the new condition
#
if cmds.isTrue('UndoNorRedo') :
print 'Neither undo nor redo is available'
else :
print 'Undo or redo is available'
cmds.condition('UndoNorRedo', delete=True)