Query name of selected display Layer?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  10 October 2010
Query name of selected display Layer?

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
 
  10 October 2010
Post Hi

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" );
 
  10 October 2010
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!
 
  10 October 2010
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)
  
 
 
 
 
  10 October 2010
Post How about this?

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()
 
 
  10 October 2010
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:25 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.