Go to: Synopsis. Return value. Flags. Python examples.
scriptNode(
[attributeList]
, [afterScript=string], [beforeScript=string], [executeAfter=boolean], [executeBefore=boolean], [ignoreReferenceEdits=boolean], [name=string], [scriptType=int], [sourceType=string])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
scriptNode is undoable, queryable, and editable.
scriptNodes contain scripts that are executed when a file is loaded or
when the script node is deleted. If a script modifies a referenced node,
the changes will be tracked as reference edits unless the scriptNode was
created with the ignoreReferenceEdits flag. The scriptNode command is used
to create, edit, query, and test scriptNodes.
None
In query mode, return type is based on queried flag.
afterScript, beforeScript, executeAfter, executeBefore, ignoreReferenceEdits, name, scriptType, sourceType
Long name (short name) |
Argument types |
Properties |
scriptType(st)
|
int
|
|
|
Specifies when the script is executed. The following
values may be used:
0 | Execute on demand. |
1 | Execute on file load or on node deletion. |
2 | Execute on file load or on node deletion
when not in batch mode. |
3 | Internal |
4 | Execute on software render |
5 | Execute on software frame render |
6 | Execute on scene configuration |
7 | Execute on time changed |
C: The default value is 0.
Q: When queried, this flag returns an int.
|
|
beforeScript(bs)
|
string
|
|
|
The script executed during file load.
C: The default is an empty string.
Q: When queried, this flag returns a string.
|
|
afterScript(afterScript)
|
string
|
|
|
The script executed when the script node is deleted.
C: The default is an empty string.
Q: When queried, this flag returns a string.
|
|
executeBefore(eb)
|
boolean
|
|
|
Execute the script stored in the .before attribute of the
scriptNode. This script is normally executed when the file
is loaded.
|
|
executeAfter(ea)
|
boolean
|
|
|
Execute the script stored in the .after attribute of the
scriptNode. This script is normally executed when the script node
is deleted.
|
|
name(n)
|
string
|
|
|
When creating a new scriptNode, this flag specifies the name
of the node. If a non-unique name is used, the name will be
modified to ensure uniqueness.
|
|
sourceType(stp)
|
string
|
|
|
Sets the language type for both the attached scripts.
Valid values are "mel" (enabled by default), and "python".
|
|
ignoreReferenceEdits(ire)
|
boolean
|
|
|
Sets whether changes made to referenced nodes during the execution of the
script should be recorded as reference edits. This flag must be set when
the scriptNode is created. If this flag is not set, changes to referenced
nodes will be recorded as edits by default.
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
# Create a scriptNode named script that creates a sphere when a file
# containing this node is loaded.
#
nodeName = cmds.scriptNode( st=2, bs='cmds.sphere()', n='script', stp='python')
# Test the before script.
#
cmds.scriptNode( nodeName, executeBefore=True )
# Add a script to create a cone when the script node is deleted.
#
cmds.scriptNode( nodeName, e=True, as='cmds.cone()', stp='python' )
# Test the after script
#
cmds.scriptNode( nodeName, executeAfter=True )