Skip to content

Instantly share code, notes, and snippets.

@danvas
Created August 26, 2011 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danvas/1172536 to your computer and use it in GitHub Desktop.
Save danvas/1172536 to your computer and use it in GitHub Desktop.
import pymel.core as pm
def chDir(object, *filtr):
"""Check methods: Returns a list of methods bound to the instanced object. Filter search with string(s) filtr."""
if not filtr:
return [meth for meth in dir(object)]
else:
return [meth for string in filtr for meth in dir(object) if string in meth]
def lightLinks(breakLink = True):
"""Make or break links of selected lights to selected meshes."""
lights = [o for o in pm.ls(sl=1) if 'Light' in pm.nodeType(o.getShape())]
meshes = [o for o in pm.ls(sl=1) if 'mesh' in pm.nodeType(o.getShape())]
if len(lights) == 0:
print("// At least one light must be selected")
if len(meshes) == 0:
print("// At least one mesh must be selected")
pm.lightlink(b = breakLink, light = lights, object = meshes)
if breakLink:
for l in lights:
print('// {0} has been unlinked to:'.format(str(l)))
for m in meshes:
print('//\t'+str(m))
print('\n')
else:
for l in lights:
print('// {0} has been linked to:'.format(str(l)))
for m in meshes:
print('//\t'+ str(m))
print('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment