MEL/Python to select all objects from a layer (from one selected object of that layer)


#1

Hello !

I have hundreds of layers.
I select an object in the scene, which is on a layer, lost in the list.
I’m looking for a shelf command to select all other objects on that layer.

Currently I grab the object’s layer name and I do “layerEditorSelectObjects layerName;”
Meaning I copy/paste the layer name for it to work.

Is there a simple way to make it work in one click after selecting an object ?

Thank you !


#2

@AwenC try something like that

import maya.cmds as mc

layer = mc.listConnections(t="displayLayer")
mc.select(layer)
nodeList = mc.listHistory(layer,f=1)
mc.select(nodeList)
mc.select(layer,d=1)

#4

Hey !

Thank you man ! It works great.
Pretty handy, it will prove quite useful.

cheers.