Skip to content

Instantly share code, notes, and snippets.

@csaez
Created January 14, 2015 15:44
Show Gist options
  • Save csaez/9b7669303af32f201460 to your computer and use it in GitHub Desktop.
Save csaez/9b7669303af32f201460 to your computer and use it in GitHub Desktop.
Maya: Remove selected cameras (including startup cameras)
from maya import cmds
def is_camera(node):
cond = (
"camera" in [cmds.nodeType(x) for x in (cmds.listRelatives(node, s=True, f=True) or [])],
cmds.nodeType(node) == "camera",
)
return any(cond)
cameras = [c for c in cmds.ls(sl=True, l=True) if is_camera(c)]
print cameras
if len(cameras):
for c in cameras:
cmds.camera(c, e=True, sc=False)
cmds.delete(cameras)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment