Go to: Synopsis. Return value. Flags. Python examples.

Synopsis

scriptNode( [attributeList] , [afterScript=string], [beforeScript=string], [executeAfter=boolean], [executeBefore=boolean], [name=string], [scriptType=int])

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. The scriptNode command is used to create, edit, query, and test scriptNodes.

Return value

None

In query mode, return type is based on queried flag.

Flags

afterScript, beforeScript, executeAfter, executeBefore, name, scriptType
Long name (short name) Argument types Properties
scriptType(st) int createqueryedit
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 createqueryedit
The script executed during file load.
C: The default is an empty string.
Q: When queried, this flag returns a string.
afterScript(afterScript) string createqueryedit
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 create
Execute the script stored in the .before attribute of the scriptNode. This script is normally executed when the file is loaded.
executeAfter(ea) boolean create
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 create
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.

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.

Python examples

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='sphere', n='script')

#    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='cone' )

#    Test the after script
#
cmds.scriptNode( nodeName, executeAfter=True )