pymel.core.system.scriptNode

scriptNode(*args, **kwargs)

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. In query mode, return type is based on queried flag.

Flags:
Long name (short name) Argument Types Properties
afterScript (afterScript) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
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) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The script executed during file load.C: The default is an empty string.Q: When queried, this flag returns a string.
executeAfter (ea) bool ../../../_images/create.gif
 
Execute the script stored in the .after attribute of the scriptNode. This script is normally executed when the script node is deleted.
executeBefore (eb) bool ../../../_images/create.gif
 
Execute the script stored in the .before attribute of the scriptNode. This script is normally executed when the file is loaded.
ignoreReferenceEdits (ire) bool ../../../_images/create.gif
 

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 commandFlag can have multiple arguments, passed either as a tuple or a list.

name (n) unicode ../../../_images/create.gif
 
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 ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

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 ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Sets the language type for both the attached scripts. Valid values are “mel” (enabled by default), and “python”.

Derived from mel command maya.cmds.scriptNode

Example:

import pymel.core as pm

#    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 )

Previous topic

pymel.core.system.sceneUIReplacement

Next topic

pymel.core.system.selLoadSettings

Core

Core Modules

Other Modules

This Page