[Durian-svn] [1289] cleanup script
campbell
institute at blender.org
Thu Mar 11 15:02:13 CET 2010
Revision: 1289
https://blenderinstitute.dyndns.org/durian-svn/?do=log&project=durian&path=/&rev=1289
Author: campbell
Date: 2010-03-11 15:02:13 +0100 (Thu, 11 Mar 2010)
Log Message:
-----------
cleanup script
Added Paths:
-----------
pro/scripts/ui/action_clear_unused.py
Added: pro/scripts/ui/action_clear_unused.py
===================================================================
--- pro/scripts/ui/action_clear_unused.py (rev 0)
+++ pro/scripts/ui/action_clear_unused.py 2010-03-11 14:02:13 UTC (rev 1289)
@@ -0,0 +1,41 @@
+import bpy
+
+class ClearUnusedActions(bpy.types.Operator):
+ ''''''
+ bl_idname = "action.clear_unused"
+ bl_label = "Clear All Unused"
+ bl_options = {'UNDO'}
+
+ def execute(self, context):
+ clear = 0
+ tot = 0
+ for act in bpy.data.actions:
+ if act.library == None:
+ users = act.users
+ if act.fake_user:
+ users -= 1
+
+ if users == 0:
+ act.user_clear()
+ clear += 1
+
+ tot += 1
+
+ self.report({'WARNING'}, "Cleared %d of %d actions! (save and reload)" % (clear, tot))
+ return {'FINISHED'}
+
+
+menu_func = (lambda self, context: self.layout.operator(ClearUnusedActions.bl_idname))
+
+
+def register():
+ bpy.types.register(ClearUnusedActions)
+ bpy.types.DOPESHEET_HT_header.append(menu_func)
+
+def unregister():
+ bpy.types.unregister(ClearUnusedActions)
+ bpy.types.DOPESHEET_HT_header.remove(menu_func)
+
+if __name__ == "__main__":
+ register()
+
More information about the Durian-svn
mailing list