Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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