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

Synopsis

scriptNode [-afterScript string] [-beforeScript string] [-executeAfter] [-executeBefore] [-ignoreReferenceEdits] [-name string] [-scriptType int] [-sourceType string] [attributeList]

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.

Return value

None

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

Flags

afterScript, beforeScript, executeAfter, executeBefore, ignoreReferenceEdits, name, scriptType, sourceType
Long name (short name) Argument types Properties
-afterScript(-as) 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.
-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.
-executeAfter(-ea) create
Execute the script stored in the .after attribute of the scriptNode. This script is normally executed when the script node is deleted.
-executeBefore(-eb) create
Execute the script stored in the .before attribute of the scriptNode. This script is normally executed when the file is loaded.
-ignoreReferenceEdits(-ire) create
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.
-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.
-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.
-sourceType(-stp) string createqueryedit
Sets the language type for both the attached scripts. Valid values are "mel" (enabled by default), and "python".

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 be used more than once in a command.

MEL examples

//    Create a scriptNode named script that creates a sphere when a file
//    containing this node is loaded.
//
string $nodeName = `scriptNode -st 2 -bs "sphere" -n "script"`;

//    Test the before script.
//
scriptNode -executeBefore $nodeName;

//    Add a script to create a cone when the script node is deleted.
//
scriptNode -e -as "cone" $nodeName;

//    Test the after script
//
scriptNode -executeAfter $nodeName;