pymel.core.general.selectionConnection

selectionConnection(*args, **kwargs)

This command creates a named selectionConnection object. This object is simply a shared selection list. It may be used by editors to share their highlight data. For example, an outliner may attach its selected list to one of these objects, and a graph editor may use the same object as a list source. Then, the graph editor would only display objects that are selected in the outliner. Selection connections are UI objects which contain a list of model objects. Selection connections are useful for specifying which objects are to be displayed within a particular editor. Editor’s have three plug socketswhere a selection connection may be attached. They are: mainListConnectionan inputsocket which contains a list of objects that are to be displayed within the editorselectionConnectionan outputsocket which contains a list of objects that are selectedwithin the editorhighlightConnectionan inputsocket which contains a list of objects that are to be highlightedwithin the editorThere are several different types of selection connections that may be created. They include: activeLista selection connection which contains a list of everything in the model which is active (which includes geometry objects and keys)modelLista selection connection which contains a list of all the geometry (i.e. excluding keys) objects that are currently activekeyframeLista selection connection which contains a list of all the keys that are currently activeworldLista selection connection which contains a list of all the objects in the worldobjectLista selection connection which contains one model object (which may be a set)listLista selection connection which contains a list of selection connectionseditorLista selection connection which contains a list of objects that are attached to the mainListConnection of the specified editorsetLista selection connection which contains a list of all the sets in the worldcharacterLista selection connection which contains a list of all the characters in the worldhighlightLista selection connection which contains a list of objects to be highlighted in some fashionBelow is an example selectionConnection network between two editors. Editor 1 is setup to display objects on the activeList. Editor 2 is setup to display objects which are selected within Editor 1, and objects that are selected in Editor 2 are highlighted within Editor 1: – Editor 1– – Editor 2– inputList–| main | | |-| main | | | | sele |–| | | sele |–| |-| high | | | high | | | | ————- ————- | |————- fromEditor2 ————-| The following commands will establish this network: selectionConnection -activeList inputList; selectionConnection fromEditor1; selectionConnection fromEditor2; editor -edit -mainListConnection inputList Editor1; editor -edit -selectionConnection fromEditor1 Editor1; editor -edit -mainListConnection fromEditor1 Editor2; editor -edit -selectionConnection fromEditor2 Editor2; editor -edit -highlightConnection fromEditor2 Editor1; Note: to delete a selection connectionuse the deleteUI commandNote: commands which expect objects may be given a selection connection instead, and the command will operate upon the objects wrapped by the selection connectionNote: the graph editor and the dope sheet are the only editors which can use the editor connection to the highlightConnection of another editorWARNING: some flag combinations may not behave as you expect. The command is really intended for internal use for managing the outliner used by the various editors.

Flags:
Long name (short name) Argument Types Properties
activeCacheList (atc) bool ../../../_images/create.gif
 
Specifies that this connection should reflect the cache that objects on the active list belong to.
activeCharacterList (acl) bool ../../../_images/create.gif
 
Specifies that this connection should reflect the characters that objects on the active list belong to.
activeList (act) bool ../../../_images/create.gif
 
Specifies that this connection should reflect the active list (geometry objects and keys).
addScript (addScript) script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify a script to be called when something is added to the selection.
addTo (add) unicode ../../../_images/create.gif ../../../_images/edit.gif
 
The name of a selection connection that should be added to this list of connections.
characterList (cl) bool ../../../_images/create.gif
 
Specifies that this connection should reflect all the characters in the world.
clear (clr) bool ../../../_images/create.gif ../../../_images/edit.gif
 
Remove everything from the selection connection.
connectionList (lst) bool ../../../_images/create.gif ../../../_images/query.gif
 
Specifies that this connection should contain a list of selection connections.
defineTemplate (dt) unicode ../../../_images/create.gif
 

Puts a command in a mode where any other flags and args are parsed and added to the command template specified in the argument. They will be used as default arguments in any subsequent invocations of the command when templateName is set as the current template.

deselect (d) PyNode ../../../_images/create.gif ../../../_images/edit.gif
 
Remove something from the selection.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.
editor (ed) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specifies that this connection should reflect the -mainListConnection of the specified editor.
exists (ex) bool ../../../_images/create.gif
 
Returns true|false depending upon whether the specified object exists. Other flags are ignored.
filter (f) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Optionally specifies an itemFilter for this connection. An empty string (“”) clears the current filter. If a filter is specified, all the information going into the selectionConnection must first pass through the filter before being accepted. NOTE: filters can only be attached to regular selectionConnections. They cannot be attached to any connection created using the -act, -mdl, -key, -wl, -sl, -cl, -lst, -obj, or -ren flags. We strongly recommend that you do not attach filters to a selectionConnection — it is better to attach your filter to the editor that is using the selectionConnection instead.

findObject (fo) PyNode ../../../_images/query.gif
 
Find a selection connection in this list that wraps the specified object.
g (g) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
A global selection connection cannot be deleted by any script commands.
highlightList (hl) bool ../../../_images/create.gif
 
Specifies that this connection is being used as a highlight list.
identify (id) bool ../../../_images/query.gif
 

Find out what type of selection connection this is. May be: activeList | modelList | keyframeList | worldList | objectList listList | editorList | connection | unknown

keyframeList (key) bool ../../../_images/create.gif
 
Specifies that this connection should reflect the animation portion of the active list.
lock (lck) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
For activeList connections, locking the connection means that it will not listen to activeList changes.
modelList (mdl) bool ../../../_images/create.gif
 
Specifies that this connection should reflect the modeling (i.e. excluding keys) portion of the active list.
object (obj) PyNode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Specifies that this connection should wrap around the specified object (which may be a set). Query will return all the members of the selection connection (if the connection wraps a set, the set members will be returned)

parent (p) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

The name of a UI object this should be attached to. When the parent is destroyed, the selectionConnection will auto-delete. If no parent is specified, the connection is created in the current controlLayout.

remove (rm) unicode ../../../_images/create.gif ../../../_images/edit.gif
 
The name of a selection connection that should be removed from this list of connections.
removeScript (rs) script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify a script to be called when something is removed from the selection.
select (s) PyNode ../../../_images/create.gif ../../../_images/edit.gif
 
Add something to the selection. This does not replace the existing selection.
setList (sl) bool ../../../_images/create.gif
 
Specifies that this connection should reflect all the sets in the world.
switch (sw) bool ../../../_images/create.gif ../../../_images/query.gif
 

Acts as a modifier to -connectionList which sets the list of objects to be the first non-empty selection connection. selection connections are tested in the order in which they are added.

useTemplate (ut) unicode ../../../_images/create.gif
 
Force the command to use a command template other than the current one.
worldList (wl) bool ../../../_images/create.gif
 
Specifies that this connection should reflect all objects in the world.

Derived from mel command maya.cmds.selectionConnection

Example:

import pymel.core as pm

import maya.cmds as cmds

#    Example 1.
#
#    Create a window with two Outliner editors and a
#    selection connection network.  Editor 1 will display the
#    current scene's active list.  Editor 2 will display the items
#    selected in Editor 1.
#
window = pm.window('window', wh=(400, 300))
pm.paneLayout( configuration='vertical2' )
# Result: ui.PaneLayout('window|paneLayout14') #
editor1 = pm.outlinerEditor()
editor2 = pm.outlinerEditor()

#    Create the selection connection network.
#
inputList = pm.selectionConnection( activeList=True )
fromEditor1 = pm.selectionConnection()
fromEditor2 = pm.selectionConnection()
pm.editor( editor1, edit=True, mainListConnection=inputList )
# Result: u'window|paneLayout14|outlinerEditor2' #
pm.editor( editor1, edit=True, selectionConnection=fromEditor1 )
# Result: u'window|paneLayout14|outlinerEditor2' #
pm.editor( editor2, edit=True, mainListConnection=fromEditor1 )
# Result: u'window|paneLayout14|outlinerEditor3' #
pm.editor( editor2, edit=True, selectionConnection=fromEditor2 )
# Result: u'window|paneLayout14|outlinerEditor3' #

pm.showWindow( window )

#    Create some objects and select them.
#
pm.sphere()
# Result: [nt.Transform(u'nurbsSphere1'), nt.MakeNurbSphere(u'makeNurbSphere1')] #
pm.cone()
# Result: [nt.Transform(u'nurbsCone1'), nt.MakeNurbCone(u'makeNurbCone1')] #
pm.cylinder()
# Result: [nt.Transform(u'nurbsCylinder1'), nt.MakeNurbCylinder(u'makeNurbCylinder1')] #
pm.select( all=True )

# Now as you select objects on the left side, they will be
# displayed on the right side.  You can also add a callback
# script to do further processing on the list when objects
# are added. (Use -removeScript for when objects are removed.)

def addScriptCallback( array ):
    print "Contents of callback array: %s\n" % array

pm.selectionConnection( fromEditor1, e=True, addScript=addScriptCallback )
# Result: u'selectionConnection2' #


#    Example 2.
#
#    Create a selection connection for a paritcular object.  Delete
#    the selection connection and the object.
#
pm.sphere( name='sphere' )
# Result: [nt.Transform(u'sphere'), nt.MakeNurbSphere(u'makeNurbSphere2')] #

#    Create a selection connection to wrap the sphere.
#
pm.selectionConnection( 'holder', object='sphere' )
# Result: u'holder' #

#    Select the sphere using the selection connection.
#
pm.select( 'holder' )

#    Delete the members (sphere) of the selection connection
#
pm.delete( 'holder' )

#    Delete the selection connection (does not delete the members of
#    the selection connection.
#
pm.deleteUI( 'holder' )
# Result: u'' #

Previous topic

pymel.core.general.selectedNodes

Next topic

pymel.core.general.setAttr

Core

Core Modules

Other Modules

This Page