Skip to content

Instantly share code, notes, and snippets.

@Roumenov
Created August 20, 2022 09:23
Show Gist options
  • Save Roumenov/d35831dade973d0233b2bb0b3ceaf9f4 to your computer and use it in GitHub Desktop.
Save Roumenov/d35831dade973d0233b2bb0b3ceaf9f4 to your computer and use it in GitHub Desktop.
iterate visibility layers and turn them off(seems to make a difference for performance when running batch ops on scenes). Haven't profiled so who knows, but things that crashed now don't. Practical heuristic ๐Ÿ™ƒ
import pymel.core as pm
layers = pm.ls(type="displayLayer")
for item in layers:
if 'defaultLayer' in item.name():
pass
else:
current_viz = item.getAttr("visibility")
print(item, current_viz)
if item.hasAttr('visibility'):
item.setAttr('visibility', False)
# for SOME reason, the button doesn't update itself when you change the layer value, lolll
#i thought this flipped that but now it's not working, will check back on never, maybe wrong attr name
#item.layerButton(edit=True, layerVisible=on)
item.setAttr('visibility',0,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment