pymel.core.general.listConnections

listConnections(*args, **kwargs)

This command returns a list of all attributes/objects of a specified type that are connected to the given object(s). If no objects are specified then the command lists the connections on selected nodes.

Modifications:
  • returns an empty list when the result is None

  • When ‘connections’ flag is True, the attribute pairs are returned in a 2D-array:

    [['checker1.outColor', 'lambert1.color'], ['checker1.color1', 'fractal1.outColor']]
    
  • added sourceFirst keyword arg. when sourceFirst is true and connections is also true,

    the paired list of plugs is returned in (source,destination) order instead of (thisnode,othernode) order. this puts the pairs in the order that disconnectAttr and connectAttr expect.

  • added ability to pass a list of types

    rtype:PyNode list
Flags:
Long name (short name) Argument Types Properties
connections (c) bool ../../../_images/create.gif
 
If true, return both attributes involved in the connection. The one on the specified object is given first. Default false.
destination (d) bool ../../../_images/create.gif
 
Give the attributes/objects that are on the “destination” side of connection to the given object. Default true.
exactType (et) bool ../../../_images/create.gif
 
When set to true, -t/type only considers node of this exact type. Otherwise, derived types are also taken into account.
plugs (p) bool ../../../_images/create.gif
 
If true, return the connected attribute names; if false, return the connected object names only. Default false;
shapes (sh) bool ../../../_images/create.gif
 
Actually return the shape name instead of the transform when the shape is “selected”. Default false.
skipConversionNodes (scn) bool ../../../_images/create.gif
 

If true, skip over unit conversion nodes and return the node connected to the conversion node on the other side. Default false.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

source (s) bool ../../../_images/create.gif
 
Give the attributes/objects that are on the “source” side of connection to the given object. Default true.
type (t) unicode ../../../_images/create.gif
 
If specified, only take objects of a specified type.

Derived from mel command maya.cmds.listConnections

Example:

import pymel.core as pm

import maya.cmds as cmds

pm.sphere( ch=True, n='BALL' )
# Result: [nt.Transform(u'BALL'), nt.MakeNurbSphere(u'makeNurbSphere1')] #
pm.setKeyframe()
# Result: 10 #
# List all connections to BALL
list = pm.listConnections('BALL')
# List only incoming connections from BALL.tx
pm.listConnections( 'BALL.tx', d=False, s=True )
# Result: [nt.AnimCurveTL(u'BALL_translateX')] #
# List connections from BALL to nodes of type 'transform'
pm.listConnections( t='transform' )
# Result: [] #
# List connections on BALL, ignoring unit conversion nodes
pm.listConnections( 'BALL', scn=True )
# Result: [nt.AnimCurveTU(u'BALL_visibility'), nt.AnimCurveTL(u'BALL_translateX'), nt.AnimCurveTL(u'BALL_translateY'), nt.AnimCurveTL(u'BALL_translateZ'), nt.AnimCurveTA(u'BALL_rotateX'), nt.AnimCurveTA(u'BALL_rotateY'), nt.AnimCurveTA(u'BALL_rotateZ'), nt.AnimCurveTU(u'BALL_scaleX'), nt.AnimCurveTU(u'BALL_scaleY'), nt.AnimCurveTU(u'BALL_scaleZ')] #

Previous topic

pymel.core.general.listAttrPatterns

Next topic

pymel.core.general.listFuture

Core

Core Modules

Other Modules

This Page