pymel.core.windows.defaultNavigation

defaultNavigation(*args, **kwargs)

The defaultNavigation command defines default behaviours when creating or manipulating connections between nodes and when navigating between nodes via those connections. This command is primarily used by attribute editors.

Flags:

Long Name / Short Name Argument Types Properties
connectToExisting / ce bool ../../../_images/create.gif
  Connect the destination (which is a node.attribute or simply node) to an existing source. If the source is specified (as node.attribute or simply as node), the command will proceed immediately. If the source is not specified, the user will be prompted to specify one. Once a source has been specified, a best guess will be made about what the user is trying to accomplish by connecting the two, based on the type of source and type of destination. The command will connect the nodes/attributes according to the best guess. The destination is specified using the destinationflag and the source specified using the sourceflag.
createNew / cn bool ../../../_images/create.gif
  Create a new node and connect it to the node.attribute specified using the destinationflag.
defaultAttribute / da bool ../../../_images/create.gif
  Returns the name of the attribute to which a connectNodeToNode would connect, given the source(attribute) and destination(node) flags. Returns a string.
defaultTraversal / dtv bool ../../../_images/create.gif
  Returns the name of the node to which it would make the most sense to navigate to from the destination node.attribute specified. The destination is specified using the destinationflag. Returns a string.
defaultWorkingNode / dwn bool ../../../_images/create.gif
  Returns the name of the node which the user is most likely to want to work with if they are interested in the attributes of the destination node. The destination is specified using the destinationflag. Returns a string.
delete / delete bool ../../../_images/create.gif
  Delete nodes with connections flowing into the node.attribute specified by the destinationflag.
destination / d PyNode ../../../_images/create.gif
  Specifies an existing destination attribute for a createNew or connectToExisting.
disconnect / dis bool ../../../_images/create.gif
  If used then disconnect the destination if it exists.
force / f bool ../../../_images/create.gif
  If set to true, then an attempt to connect a source attribute to a destination attribute which already has a source will cause the existing source to be disconnected and the new source to be connected in its place. Default value is true.
ignore / i bool ../../../_images/create.gif
  Ignore any connections flowing into the node.attribute specified by the destinationflag.
navigatorDecisionString / nds unicode ../../../_images/create.gif
  This is your opportunity to pass the navigator a string that can help it decide what behaviour to execute.
quiet / qt bool ../../../_images/create.gif
  If set to true, then under no circumstances should the user be prompted for more information. Default value is false.
relatedNodes / ren bool ../../../_images/create.gif
  List nodes which are conceptually related to the node.attribute specified by the destination. Related nodes may include, but are not limited to, nodes which are directly or indirectly connected to the destination. The destination is specified using the destinationflag. Returns an array of strings.
source / s PyNode ../../../_images/create.gif
  Specifies an existing source attribute for a connectToExisting.
unignore / u bool ../../../_images/create.gif
  Stop ignoring any connections flowing into the node.attribute specified by the destinationflag. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.defaultNavigation

Example:

import pymel.core as pm

# Create a poly plane
pm.polyPlane(w=10, h=10, sx=10, sy=10, n='pPlane1')
# Result: [nt.Transform(u'pPlane1'), nt.PolyPlane(u'polyPlane1')] #

# This will open the Create Render Node window from which you can select a node that you want to connect to the existing lambert1.color attribute
pm.defaultNavigation(createNew=True, destination='lambert1.color')

# Select the Checker Node, you will find "checker1.outColor" is connected to "lambert1.color"

# Break the connection between "checker1.outColor" and "lambert1.color" you have just established
pm.disconnectAttr('checker1.outColor', 'lambert1.color')

# Connect "checker1" to "lambert1". Only node is specified here, but the command will make a best guess.
# So "checker1.outColor" and "lambert1.color" are connected
pm.defaultNavigation(connectToExisting=True, source='checker1', destination='lambert1')