PDA

View Full Version : Query name of selected display Layer?


surreal-reality
10-20-2010, 05:37 PM
I'm trying to write a super simple script that toggles bounding box / full mode for whatever display layer is selected. I have everything else worked out but is there a way to query the display layer's name?

Thanks,

Lucas

norbertnacu
10-20-2010, 08:28 PM
Please try this:

string $selLayer = (`editDisplayLayerGlobals -q -cdl` == "defaultLayer") ? "" : (`editDisplayLayerGlobals -q -cdl`);
if( size( $selLayer ) != 0 )
print( "Selected layer: " + $selLayer );
else
warning( "Please select 1 layer" );

surreal-reality
10-20-2010, 08:59 PM
I'm actually doing this in python, but querying that specific cdl flag spits out the name of the selected display layer. Absolutely awesome, I had no idea, I thought that function had to do with setting or querying a name on creation, or something like that.

Thanks a ton norbertnacu!

surreal-reality
10-20-2010, 10:59 PM
This is what I ended up with python wise. Maybe it will be useful. Thanks again



import maya.cmds as cmds lyrName = str(cmds.editDisplayLayerGlobals(q = 1, cdl = 1))
lodVar = cmds.getAttr("%s.levelOfDetail" % (lyrName))
if(lodVar == 0):
cmds.setAttr("%s.levelOfDetail" % (lyrName), 1)
if(lodVar == 1):
cmds.setAttr("%s.levelOfDetail" % (lyrName), 0)

norbertnacu
10-20-2010, 11:44 PM
import maya.cmds as cmds
import maya.mel as mel

def SurrealToggle():
status = False
lyrName = str(cmds.editDisplayLayerGlobals(q=1, cdl=1))

if lyrName != "defaultLayer":
cmds.setAttr(("%s.lod"%lyrName), not cmds.getAttr("%s.lod"%lyrName))
else:
mel.eval('error("Please select a valid layer" )')
status = True

return status

SurrealToggle()

CGTalk Moderation
10-20-2010, 11:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.