Skip to content

Instantly share code, notes, and snippets.

@fereria
Last active July 14, 2017 09:44
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 fereria/bd3129389a1ebb7254750306cda87be4 to your computer and use it in GitHub Desktop.
Save fereria/bd3129389a1ebb7254750306cda87be4 to your computer and use it in GitHub Desktop.
import pymel.core as pm
default = ['TurtleDefaultBakeLayer','defaultLightSet','defaultObjectSet','initialParticleSE','initialShadingGroup']
set_list = [x for x in pm.ls(type="objectSet") if x.name() not in default]
cmd_list = []
for set in set_list:
if set.isReferenced() is True:
continue
object = set.elements()
if len(object) != 0:
cmd_list.append("select -r " + " ".join([x.name() for x in object]) + ";")
cmd_list.append('sets -name "{0}";'.format(set.name()))
cmd_list.append("select -cl;")
save_file = pm.fileDialog(m=1,dm="*.mel")
if save_file is not None:
with open(save_file,'w') as f:
f.write("\n".join(cmd_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment