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

Synopsis

nodePreset([attributes=string], [custom=string], [delete=[name, string]], [exists=[name, string]], [isValidName=string], [list=name], [load=[name, string]], [save=[name, string]])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

nodePreset is NOT undoable, NOT queryable, and NOT editable.

Command to save and load preset settings for a node. This command allows you to take a snapshot of the values of all attributes of a node and save it to disk as a preset with user specified name. Later the saved preset can be loaded and applied onto a different node of the same type. The end result is that the node to which the preset is applied takes on the same values as the node from which the preset was generated had at the time of the snapshot.

Return value

booleanif isValidName or exists is used.

Keywords

preset, render, globals

Flags

attributes, custom, delete, exists, isValidName, list, load, save
Long name (short name) Argument types Properties
attributes(atr) string create
A white space separated string of the named attributes to save to the preset file. If not specified, all attributes will be stored.
custom(ctm) string create
Specifies a MEL script for custom handling of node attributes that are not handled by the general save preset mechanism (ie. multis, dynamic attributes, or connections). The identifiers #presetName and #nodeName will be expanded before the script is run. The script must return an array of strings which will be saved to the preset file and issued as commands when the preset is applied to another node. The custom script can query #nodeName in determining what should be saved to the preset, or issue commands to query the selected node in deciding how the preset should be applied.
delete(delete) [name, string] create
Deletes the existing preset for the node specified by the first argument with the name specified by the second argument.
exists(ex) [name, string] create
Returns true if the node specified by the first argument already has a preset with a name specified by the second argument. This flag can be used to check if the user is about to overwrite an existing preset and thereby provide the user with an opportunity to choose a different name.
isValidName(ivn) string create
Returns true if the name consists entirely of valid characters for a preset name. Returns false if not. Because the preset name will become part of a file name and part of a MEL procedure name, some characters must be disallowed. Only alphanumeric characters and underscore are valid characters for the preset name.
list(ls) name create
Lists the names of all presets which can be loaded onto the specified node.
load(ld) [name, string] create
Sets the settings of the node specified by the first argument according to the preset specified by the second argument. Any attributes on the node which are the destinations of connections or whose children (multi children or compound children) are destinations of connections will not be changed by the preset.
save(sv) [name, string] create
Saves the current settings of the node specified by the first argument to a preset of the name specified by the second argument. If a preset for that node with that name already exists, it will be overwritten with no warning. You can use the -exists flag to check if the preset already exists. If an attribute of the node is the destination of a connection, the value of the attribute will not be written as part of the preset.

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

# To determine if "My Special Settings" is a valid name for a preset (it
# is not because it contains spaces):
#
cmds.nodePreset(isValidName="My Special Settings" )
# Result: 0 #
# To save the settings of nurbsSphereShape1 as a preset called "smithers":
#
cmds.nodePreset( save=("nurbsSphereShape1","smithers") )
# To get a list of all presets available that could be applied to
# nurbsSphereShape1:
#
cmds.nodePreset( list='nurbsSphereShape1' )
# Result: [u'smithers', u'smoothSphere', u'roughSphere', u'atmoSphere'] #
# To load the preset named "smoothSphere" onto nurbsSphereShape1:
#
cmds.nodePreset( load=('nurbsSphereShape1', 'smoothSphere') )
# To delete the preset named "smithers" which was formerly available for the
# node nurbsSphereShape1 (and other nodes of the same type):
#
cmds.nodePreset( delete=('nurbsSphereShape1', 'smithers') )
# To determine if a preset named "smithers" exists for the node
# nurbsSphereShape1 (it does not because it has been deleted):
#
cmds.nodePreset( exists=('nurbsSphereShape1', 'smithers') )
# Result: 0 #
# Create a preset containing only the color and diffuse attributes:
#
cmds.nodePreset( save=("lambert1","colorAndDiffuse"), attributes='color diffuse' )
# Create a preset to map a checker texture to the applied node.
# Because the "custom" callback is required to return an array of MEL commands,
# each line of python in the array must be wrapped by the MEL "python" command.
#
def customChecker():
    doCheckerCmds = [
		# Get the name of the node to apply the checker to.
	 	"python( \"selection = cmds.ls( selection=True )\" );",
	    "python( \"nodeName = selection[0]\" );",
	    # Create a checker texture.
	    "python( \"checkerName = cmds.shadingNode( 'checker', asTexture=True )\" );",
	    # Connect the checker to the node the preset is applied to.
		"python( \"cmds.connectAttr( (checkerName+\\\".outColor\\\"), (nodeName+\\\".color\\\") )\" );"
		]
    return doCheckerCmds
	cmds.nodePreset(custom="python( \"customChecker()\" )", save=('lambert1', 'checkered') )