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
- returns an empty list (with a warning) when the arg is an empty list, tuple,
set, or frozenset, making it’s behavior consistent with when None is passed, or no args and nothing is selected (would formerly raise a TypeError)
When ‘connections’ flag is True, (and ‘plugs’ is True) the attribute pairs are returned in a 2D-array:
[['checker1.outColor', 'lambert1.color'], ['checker1.color1', 'fractal1.outColor']] Note that if 'plugs' is False (the default), for backward compatibility, the returned pairs are somewhat less intuitive attrs + nodes:: [['checker1.outColor', 'lambert1'], ['checker1.color1', 'fractal1']]
- 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 If true, return both attributes involved in the connection. The one on the specified object is given first. Default false. destination / d bool Give the attributes/objects that are on the destinationside of connection to the given object. Default true. exactType / et bool When set to true, -t/type only considers node of this exact type. Otherwise, derived types are also taken into account. plugs / p bool If true, return the connected attribute names; if false, return the connected object names only. Default false; shapes / sh bool Actually return the shape name instead of the transform when the shape is selected. Default false. skipConversionNodes / scn bool If true, skip over unit conversion nodes and return the node connected to the conversion node on the other side. Default false. source / s bool Give the attributes/objects that are on the sourceside of connection to the given object. Default true. type / t unicode If specified, only take objects of a specified type. Flag can have multiple arguments, passed either as a tuple or a list. Derived from mel command maya.cmds.listConnections
Example:
import pymel.core as pm 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')] #