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. In query mode, return type is based on queried flag.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
afterScript (afterScript) | unicode | ||
|
|||
beforeScript (bs) | unicode | ||
|
|||
executeAfter (ea) | bool | ||
|
|||
executeBefore (eb) | bool | ||
|
|||
name (n) | unicode | ||
|
|||
scriptType (st) | int | ||
Specifies when the script is executed. The following values may be used: 0Execute on demand.1Execute on file load or on node deletion.2Execute on file load or on node deletion when not in batch mode.3Internal4Execute on software render5Execute on software frame render6Execute on scene configuration7Execute on time changedC: The default value is 0.Q: When queried, this flag returns an int. |
|||
sourceType (stp) | unicode | ||
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 commandFlag can have multiple arguments, passed either as a tuple or a list. |
Derived from mel command maya.cmds.scriptNode
Example:
import pymel.core as pm
import maya.cmds as cmds
# Create a scriptNode named script that creates a sphere when a file
# containing this node is loaded.
#
nodeName = pm.scriptNode( st=2, bs='pm.sphere()', n='script', stp='python')
# Test the before script.
#
pm.scriptNode( nodeName, executeBefore=True )
# Add a script to create a cone when the script node is deleted.
#
pm.scriptNode( nodeName, e=True, as='pm.cone()', stp='python' )
# Test the after script
#
pm.scriptNode( nodeName, executeAfter=True )