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

Synopsis

selectionConnection( string , [activeCacheList=boolean], [activeCharacterList=boolean], [activeList=boolean], [addScript=script], [addTo=string], [characterList=boolean], [clear=boolean], [connectionList=boolean], [defineTemplate=string], [deselect=name], [editor=string], [exists=boolean], [filter=string], [findObject=name], [g=boolean], [highlightList=boolean], [identify=boolean], [keyframeList=boolean], [lock=boolean], [modelList=boolean], [object=name], [parent=string], [remove=string], [removeScript=script], [select=name], [setList=boolean], [switch=boolean], [useTemplate=string], [worldList=boolean])

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

selectionConnection is undoable, queryable, and editable.

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 sockets where a selection connection may be attached. They are:

mainListConnection
an input socket which contains a list of objects that are to be displayed within the editor

selectionConnection
an output socket which contains a list of objects that are selected within the editor

highlightConnection
an input socket which contains a list of objects that are to be highlighted within the editor

There are several different types of selection connections that may be created. They include:

activeList
a selection connection which contains a list of everything in the model which is active (which includes geometry objects and keys)

modelList
a selection connection which contains a list of all the geometry (i.e. excluding keys) objects that are currently active

keyframeList
a selection connection which contains a list of all the keys that are currently active

worldList
a selection connection which contains a list of all the objects in the world

objectList
a selection connection which contains one model object (which may be a set)

listList
a selection connection which contains a list of selection connections

editorList
a selection connection which contains a list of objects that are attached to the mainListConnection of the specified editor

setList
a selection connection which contains a list of all the sets in the world

characterList
a selection connection which contains a list of all the characters in the world

highlightList
a selection connection which contains a list of objects to be highlighted in some fashion

Below 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 connection use the deleteUI command
Note: commands which expect objects may be given a selection connection instead, and the command will operate upon the objects wrapped by the selection connection
Note: the graph editor and the dope sheet are the only editors which can use the editor connection to the highlightConnection of another editor
WARNING: 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.

Return value

string

In query mode, return type is based on queried flag.

Flags

activeCacheList, activeCharacterList, activeList, addScript, addTo, characterList, clear, connectionList, defineTemplate, deselect, editor, exists, filter, findObject, g, highlightList, identify, keyframeList, lock, modelList, object, parent, remove, removeScript, select, setList, switch, useTemplate, worldList
Long name (short name) Argument types Properties
activeCacheList(atc) boolean create
Specifies that this connection should reflect the cache that objects on the active list belong to.
activeCharacterList(acl) boolean create
Specifies that this connection should reflect the characters that objects on the active list belong to.
activeList(act) boolean create
Specifies that this connection should reflect the active list (geometry objects and keys).
addScript(addScript) script createqueryedit
Specify a script to be called when something is added to the selection.
addTo(add) string createedit
The name of a selection connection that should be added to this list of connections.
characterList(cl) boolean create
Specifies that this connection should reflect all the characters in the world.
clear(clr) boolean createedit
Remove everything from the selection connection.
connectionList(lst) boolean createquery
Specifies that this connection should contain a list of selection connections.
defineTemplate(dt) string create
Puts the 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) name createedit
Remove something from the selection.
editor(ed) string createqueryedit
Specifies that this connection should reflect the -mainListConnection of the specified editor.
exists(ex) boolean create
Returns whether the specified object exists or not. Other flags are ignored.
filter(f) string createqueryedit
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) name query
Find a selection connection in this list that wraps the specified object.
g(g) boolean createqueryedit
A global selection connection cannot be deleted by any script commands.
highlightList(hl) boolean create
Specifies that this connection is being used as a highlight list.
identify(id) boolean query
Find out what type of selection connection this is. May be: activeList | modelList | keyframeList | worldList | objectList listList | editorList | connection | unknown
keyframeList(key) boolean create
Specifies that this connection should reflect the animation portion of the active list.
lock(lck) boolean createqueryedit
For activeList connections, locking the connection means that it will not listen to activeList changes.
modelList(mdl) boolean create
Specifies that this connection should reflect the modeling (i.e. excluding keys) portion of the active list.
object(obj) name createqueryedit
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) string createqueryedit
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) string createedit
The name of a selection connection that should be removed from this list of connections.
removeScript(rs) script createqueryedit
Specify a script to be called when something is removed from the selection.
select(s) name createedit
Add something to the selection. This does not replace the existing selection.
setList(sl) boolean create
Specifies that this connection should reflect all the sets in the world.
switch(sw) boolean createquery
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) string create
Force the command to use a command template other than the current one.
worldList(wl) boolean create
Specifies that this connection should reflect all objects in the world.

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

#    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 = cmds.window('window', wh=(400, 300))
cmds.paneLayout( configuration='vertical2' )
editor1 = cmds.outlinerEditor()
editor2 = cmds.outlinerEditor()

#    Create the selection connection network.
#
inputList = cmds.selectionConnection( activeList=True )
fromEditor1 = cmds.selectionConnection()
fromEditor2 = cmds.selectionConnection()
cmds.editor( editor1, edit=True, mainListConnection=inputList )
cmds.editor( editor1, edit=True, selectionConnection=fromEditor1 )
cmds.editor( editor2, edit=True, mainListConnection=fromEditor1 )
cmds.editor( editor2, edit=True, selectionConnection=fromEditor2 )

cmds.showWindow( window )

#    Create some objects and select them.
#
cmds.sphere()
cmds.cone()
cmds.cylinder()
cmds.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

cmds.selectionConnection( fromEditor1, e=True, addScript=addScriptCallback )


#    Example 2.
#
#    Create a selection connection for a paritcular object.  Delete
#    the selection connection and the object.
#
cmds.sphere( name='sphere' )

#    Create a selection connection to wrap the sphere.
#
cmds.selectionConnection( 'holder', object='sphere' )

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

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

#    Delete the selection connection (does not delete the members of
#    the selection connection.
#
cmds.deleteUI( 'holder' )