Skip to content

Instantly share code, notes, and snippets.

@Onefabis
Created April 12, 2016 12:36
Show Gist options
  • Save Onefabis/d39e364e8eb2a2e31e76f5097241e1bb to your computer and use it in GitHub Desktop.
Save Onefabis/d39e364e8eb2a2e31e76f5097241e1bb to your computer and use it in GitHub Desktop.
Toggle all visible layers in 'layer editor' to Referenced/None state
layers = cmds.ls( type='displayLayer')
global chLayViz
#Checks if 'chLayViz' variable exists and if not - assign 'None'
try:
chLayViz
except NameError:
chLayViz = None
# Assign toggle value to 'chLayViz' var
if chLayViz == 0 :
chLayViz = 1
elif chLayViz == 1 or chLayViz == None :
chLayViz = 0
# Check all visible layers and toggle the 'Referenced' state
for l in layers[1:]:
if cmds.getAttr( l + '.visibility') == True:
if chLayViz == 1:
cmds.setAttr( l + '.displayType', 2)
elif chLayViz == 0:
cmds.setAttr( l + '.displayType', 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment