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

Synopsis

callbacks([addCallback=script], [clearAllCallbacks=boolean], [clearCallbacks=boolean], [describeHooks=boolean], [dumpCallbacks=boolean], [executeCallbacks=boolean], [hook=string], [listCallbacks=boolean], [owner=string], [removeCallback=script])

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

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

This command allows you to add callbacks at key times during UI creation so that the Maya UI can be extended. The list of standard Maya hooks, as well as the arguments which will be passed to the callback based on the context are enumerated in the describeHooks section below. Custom hooks can also be added if third parties want to add UI extensibility to their plugins.

Return value

string[]

Keywords

ui, callback

Flags

addCallback, clearAllCallbacks, clearCallbacks, describeHooks, dumpCallbacks, executeCallbacks, hook, listCallbacks, owner, removeCallback
Long name (short name) Argument types Properties
owner(o) string create
The name of the owner registering the callback. This is typically a plugin name.
hook(h) string create
The name of the hook for which the callback should be registered.
addCallback(ac) script create
Add a callback for the specified hook. The owner must also be specified when adding callbacks.
removeCallback(rc) script create
Remove an existing callback for the specified hook name. The owner must also be specified when removing a callback.
clearCallbacks(cc) boolean create
Clear all the callbacks for the specified owner. If a hook is specified, only the callbacks for that hook and owner will be cleared.
listCallbacks(lc) boolean create
Get the list of callbacks for the specified hook name. If the owner is specified, only callbacks for the specified hook and owner will be listed.
clearAllCallbacks(cac) boolean create
Clear all the callbacks for all hooks and owners. This is generally only used during plugin development and testing as it affects all callbacks registered by Maya and other third parties.
executeCallbacks(ec) boolean create
Execute the callbacks for the specified hook, passing the extra arguments to each callback when it is executed. Returns an array (MEL) or list (Python) containing the return values from each callback that was executed. If a callback returns no value, the array will contain an empty string (MEL) or None (Python).
dumpCallbacks(dc) boolean create
Gives a list of all the registered callbacks for all hooks and owners. Can be useful for debugging.
describeHooks(dh) boolean create
List the standard Maya hooks. Below is a list of the hooks and their associated arguments and return values. Custom hooks added by third parties are not listed.

hyperShadePanelBuildCreateMenu
This hook is called to add content to the Hypershade panel create menu. It will be called after the standard Maya node entries have been created.

This callback does not have any arguments or return values. In order to preserve the desired look in the Maya UI, these callbacks should add a menu item divider just before returning using: menuItem -divider true.

hyperShadePanelBuildCreateSubMenu
This hook is called to get a classification string for the custom renderer shading nodes, to prevent them from being listed with the standard Maya nodes.

This callback does not have any arguments.

  • returns: a classification string, such as rendernode/myrenderer
hyperShadePanelPluginChange
This hook is called when a plugin change event (loading / unloading) has occurred to inform Maya whether the Hypershade panel needs to be rebuilt.
  • classification (string): classification string belonging to a plugin node, possibly from another plugin
  • changeType (string): either loadPlugin or unloadPlugin
  • returns: (int) non-zero if your plugin is responsible for nodes of this classification, and a Hypershade rebuild is required
createRenderNodeSelectNodeCategories
This hook is called when the Create Render Node dialog is being constructed, and allows a third party to have their nodes selected by default. A flag of the form -allWithMyRendererUp is the standard form, and the selection can be set up in the tree lister in the callback.

There is no return value for this callback.

  • flag (string): flag passed to the Create Render Node dialog command with the leading minus (-) removed
  • treeLister (string): the tree lister widget which should be affected

For example, your callback might look like:

global proc myRendererCreateRenderNodeSelectNodeCategoriesCallback(string $flag, string $treeLister){
    if($flag == "allWithMyRendererUp") {
        treeLister -e -selectPath "myrenderer" $treeLister;
    }
}
createRenderNodePluginChange
This hook is called when a plugin change event has occurred to decide if the Create Render Node dialog needs to be closed.
  • classification (string): classification string belonging to a plugin node, possibly from another plugin
  • returns: (int) non-zero if your plugin is responsible for nodes of this classification, and the Create Render Node dialog needs to be closed
renderNodeClassification
This hook is called to get a classification string for the custom renderer shading nodes. This is used to determine if a given node type belongs to a plugin renderer.

This callback does not have any arguments.

  • returns: a classification string, such as rendernode/myrenderer
createRenderNodeCommand
This hook is called to give plugin renderers the chance to register their own command for creating their nodes from the render node treeLister and Node Editor. The callback should determine from the classification of the node type in question if it is theirs, and if so, return the appropriate command for creating new nodes of that type.

  • postCommand (string): command to be run after the create command
  • type (string): nodeType
  • returns: (string) MEL create command
buildRenderNodeTreeListerContent
This hook is called to give plugin renderers the chance to add their content to the render node tree lister.

  • renderNodeTreeLister (string): the render node tree lister
  • postCommand (string): command to be run post-creation
  • filterString (string): a space delimited list of filters
AETemplateCustomContent
This hook is called to give plugins a chance to add content to the Attribute Editor for nodes which source AEdependNodeTemplate.

  • nodeName (string): the name of the node for which the Attribute Editor is being constructed
firstConnectedShader
This hook is called to determine the primary custom shader connected to the given Shading Engine.

  • nodeName (string): the name of the Shading Engine
  • returns (string): the name of the custom shader if applicable
allConnectedShaders
This hook is called to determine all the shaders connected to the given Shading Engine.

  • nodeName (string): the name of the Shading Engine
  • returns (string): a colon separated list of the connected custom shaders (shader1:shader2:shader3)
renderLayerPresetMenu
This hook is called to give plugins a chance to add presets to a renderLayer node.

  • nodeName (string): the name of the renderLayer node
addBakingMenuItems
This hook is called to give plugins a chance to add baking menu items to the global Render - Lighting/Shading menu.

  • menuItemAnchor (string): the name of the menuItem which the new baking menu items should be inserted after.
addVertexBakingMenuItems
This hook is called to give plugins a chance to add baking menu items to the global Polygon - Color menu.

addPrelightMenuItems
This hook is called to give plugins a chance to add pre-lighting menu items to the global Polygon - Color Set Editor menu.

addRMBBakingMenuItems
This hook is called to give plugins a chance to add baking menu items to the RMB menu.

  • objectName (string): the name of the object the right mouse button event occured on.
addMayaRenderingPreferences
This hook is called to give plugins a chance to add custom preferences to the Maya's Rendering Preferences section.

updateMayaRenderingPreferences
This hook is called to give plugins a chance to update custom preferences of the Maya's Rendering Preferences section.

addMayaMuscleMenuItems
This hook is called to give plugins a chance to add menu items to the Maya muscle Displace menu.

  • menuItemAnchor (string): the name of the menuItem which the new Maya muscle menu items should be inserted after.
addMayaMuscleShelfButtons
This hook is called to give plugins a chance to add items to the Maya muscle shelves.

addBackburnerRendererMenuItems
This hook is called to give plugins a chance to add items to Maya's Backburner list of available renderers. Note: The menuItem added must be named with the short name equivalent of the renderer. eg: The Maya software renderer adds a menuItem named 'sw'.

provideAETemplateForNodeType
This hook is called to give plugins a chance to provide a UI template for nodes which do not have a corresponding AE'nodeType'Template procedure.

  • nodeType (string): the type of the node for which the AE is being constructed.
  • returns (string): the name of a MEL command or procedure to use as the AETemplate for the requested node type.
AEnewMultiHandler
This hook is called to give plugins a chance to provide a UI creation handler for multi attributes.

  • nodeName (string): the name of the node for which the AE is being constructed.
  • atributeName (string): the name of the multi attribute.
  • uiName (string): the UI name of the attribute.
  • changedCommand (string): the MEL command or procedure to be executed when the value of the multi attribute is changed.
  • elementIndexString (string): a colon separated list of indices at which the elements of the multi attribute live.
  • returns (string): if the callback handled the attribute then it should return the full name of the topmost UI element that it created, otherwise it should return an empty string.
AEreplaceMultiHandler
This hook is called to give plugins a chance to provide an update handler for multi attributes.

  • layoutName (string): the well defined name of the Maya UI component which represents the multi attribute (.
  • nodeName (string): the name of the node for which the AE is being constructed.
  • atributeName (string): the name of the multi attribute.
  • changedCommand (string): the MEL command or procedure to be executed when the value of the multi attribute is changed.
  • elementIndexString (string): a colon separated list of indices at which the elements of the multi attribute live.
  • returns (int): true (1) if the callback handled the multi attribute, false (0) if Maya should provide its default handling.
AEnewAttributeHandler
This hook is called to give plugins a chance to provide a UI creation handler for attributes.

  • nodeName (string): the name of the node for which the AE is being constructed.
  • atributeName (string): the name of the attribute.
  • uiName (string): the UI name of the attribute.
  • changedCommand (string): the MEL command or procedure to be executed when the value of the attribute is changed.
  • returns (string): if the callback handled the attribute then it should return the full name of the topmost UI element that it created, otherwise it should return an empty string.
AEreplaceAttributeHandler
This hook is called to give plugins a chance to provide an update handler for attributes.

  • nodeName (string): the name of the node for which the AE is being constructed.
  • atributeName (string): the name of the attribute.
  • changedCommand (string): the MEL command or procedure to be executed when the value of the attribute is changed.
  • returns (int): true (1) if the callback handled the attribute, false (0) if Maya should provide its default handling.
provideClassificationStrings
This hook must be supplied by all third parties that add nodes to the 'shader/surface' classification namespace.

  • returns (string): a colon separated list representing the different plugin node classifications.
provideClassificationStringsForFilteredTreeLister
This hook is called by 'createAssignNewMaterialTreeLister' and gives plugins a chance to append to the classification filter passed to the Tree Lister builder. It must return a string where each new classification is separated by a white space.

  • currentFilterString (string): a white-space-separated string representing the current classifications.
nodeCanBeUsedAsMaterial
The hook is used by the RMB 'Assign Favorite Material' menu to determine which shading nodes can be used as materials. It must return 'true' if the node can be used as a material node and 'false' otherwise.

  • nodeId (string): the node Id of the shading node being queried.
  • nodeOwner (string): the name of the plugin the node belongs to.
addHeaderContentToMayaLambertianShadersAE
This hook is called to give plugins a chance to add content to the header of the Attribute Editor of Maya's Lambertian-​derived shaders.

  • nodeName (string): the name of the node for which the Attribute Editor is being constructed.
provideOutputAttributeNameForTextureNode
This hook is called to give plugins a chance to provide a different output attribute name for Texture nodes. If this hook isn't provided 'outColor' is used.

  • nodeName (string): the name of the texture node queried.
  • returns (string): the output attribute name of the Texture node.
addItemsToHypergraphNodePopupMenu
This hook is called to give plugins a chance to add items to the Hypergraph node popup menu.

  • nodeName (string): the name of the node for which the Hypergraph node menu is being constructed.
addItemsToRenderLayerEditorPopupMenu
This hook is called to give plugins a chance to add items to the Render Layer Editor popup menu.

  • layerName (string): the name of the render layer for which the popup menu is being constructed.
preventMaterialDeletionFromCleanUpSceneCommand
This hook is called by the cleanUpScene command and gives the plugin a chance to communicate that a material node is still in use and shouldn't be deleted. The hook is called once per plug/connection pair of each shader instance.

  • shader (string): the name of the shader node being deleted.
  • plug (string): the name of the plug queried.
  • connection (string): the name of the connection queried.
connectNodeToNodeOverrideCallback
This hook is called to give plugins a chance to redefine the behavior of drag and drop.

  • srcNode (string): the name of the source node (the dragged node).
  • dstNode (string): the name of the destination node (the dropped-on node).
  • returns (int): Return 1 if Maya should perform the operation that would normally result from this connection. Return 0 to override and provide custom behavior.

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

def myCallbackFunction(arg1, arg2):
		return arg1 + arg2
# add a new callback for myPlugin to be called when creating the attribute editor UI
cmds.callbacks(addCallback=myCallbackFunction, hook='desiredHook', owner='myPlugin')
# remove an individual callback
cmds.callbacks(removeCallback=myCallbackFunction, hook='desiredHook', owner='myPlugin')
# remove all callbacks for myPlugin for a specified hook
cmds.callbacks(clearCallbacks=True, hook='desiredHook', owner='myPlugin')
# remove all callbacks for myPlugin for all hooks
cmds.callbacks(clearCallbacks=True, owner='myPlugin')
# list callbacks for a specified hook
callbacks = cmds.callbacks(listCallbacks=True, hook='desiredHook')
# list callbacks for a specified hook and for a specified owner
callbacks = cmds.callbacks(listCallbacks=True, hook='desiredHook', owner='myPlugin')
# get a list of the standard Maya hooks
cmds.callbacks(describeHooks=True)
# execute the callbacks for the hook 'desiredHook'
results = cmds.callbacks('arg1', 'arg2', executeCallbacks=True, hook='desiredHook')