def save(self):
scn = bpy.context.scene
cats = set([cat.name for cat in self.cats])
libpath = bpy.context.scene.matlib.current_library.path
cmd = """
print(30*"+")
import bpy
if not hasattr(bpy.context.scene, "matlib_categories"):
class EmptyProps(bpy.types.PropertyGroup):
pass
bpy.utils.register_class(EmptyProps)
bpy.types.Scene.matlib_categories = bpy.props.CollectionProperty(type=EmptyProps)
cats = bpy.context.scene.matlib_categories
for cat in cats:
cats.remove(0)
"""
for cat in cats:
cmd += """
cat = cats.add()
cat.name = "%s" """ % cat.capitalize()
cmd +='''
bpy.ops.wm.save_mainfile(filepath="%s", check_existing=False, compress=True)''' % winpath(libpath)
return send_command(cmd, "save_categories.py")
评论列表
文章目录