Go to: Related nodes. Attributes.

Script nodes hold MEL code as part of a scene file. They are also set up to (possibly) execute after loading from a file, just before closing a file, or just before the node is deleted.

The before scripts are executed when a file is loaded. If a file is closed or the node is deleted, the after script is executed. If a scene contains several script nodes, there is no guaranteed order of execution and the scripts should not depend on a specific execution sequence.

The scriptType attribute accepts three different enumerated values that are used to determine if and when a script is executed. The after script will execute when the node is deleted regardless of the scriptType value.

Enum Type Description
0 Demand The scripts are only executed if explicitly requested with the scriptNode command. The after script will execute if the node is deleted.
1 Open/Close The before script will execute when the file is read. The after script will execute when the file is closed. The file is closed immediately after a file new is issued, but while the file is still in memory; before a file open of a different file; or if the file is de-referenced. The after script will execute when the node is deleted.
2 GUI Open/Close The script will only execute during file open and close when Maya is in full GUI mode, not in batch mode. The after script will execute when the node is deleted.
3 UI Configuration (Internal) An internally used enum which indicates the script is used to store the UI configuration for a scene. Any script node with this enum may be deleted or changed without notice.
4 Software Render The before script will execute immediately before a software render starts. The after script executes when the software render is finished.
5 Software Frame Render The before script executes before a frame is software rendered. The after script is executed after the frame is rendered.
6 Scene Configuration (Internal) An internally used enum which indicates the script is used to store the configuration information for a scene. Any script node with this enum may be deleted or changed without notice.
7 Time Changed (Internal) The script executes if the time is changed.

Node nameParentsMFn typeCompatible function sets
scriptdependNodekScriptkBase
kNamedObject
kDependencyNode
kScript

Related nodes

deleteComponent, arrayMapper

Attributes (3)

after, before, scriptType

Long name (short name)TypeDefaultFlags
before (b) stringNULLoutputinputconnectablestorable
The script to execute when the file is opened.
after (a) stringNULLoutputinputconnectablestorable
The script to execute when the file is closed or the node is deleted.
scriptType (st) enum0outputinputconnectablestorable
Sets the conditions for executing the scripts. The following are legal values: 0 = Demand, 1 = Open/Close, 2 = GUI Open/Close, 3 = UI Configuration (Internal), 4 = Software Render, 5 = Software Frame Render, 6 = Scene Configuration (Internal) 7 = Time Changed