[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37365] branches/soc-2011-pepper/release/ scripts/startup/bl_ui/properties_scene.py: Added operator to make importing Keying Sets from files easier.

Joshua Leung aligorith at gmail.com
Fri Jun 10 14:43:06 CEST 2011


Revision: 37365
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37365
Author:   aligorith
Date:     2011-06-10 12:43:06 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
Added operator to make importing Keying Sets from files easier.

This can be found from the dropdown below the Add/Remove buttons in
the Properties Editor -> Scene -> Keying Sets panel.

Modified Paths:
--------------
    branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_scene.py

Modified: branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_scene.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_scene.py	2011-06-10 12:08:55 UTC (rev 37364)
+++ branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_scene.py	2011-06-10 12:43:06 UTC (rev 37365)
@@ -76,6 +76,7 @@
         col = row.column(align=True)
         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
+        col.menu("SCENE_MT_keying_set_specials", icon='DOWNARROW_HLT', text="")
 
         ks = scene.keying_sets.active
         if ks and ks.is_path_absolute:
@@ -94,6 +95,14 @@
             col.prop(ks, "bl_options")
 
 
+class SCENE_MT_keying_set_specials(bpy.types.Menu):
+    bl_label = "Keying Set Specials"
+
+    def draw(self, context):
+        layout = self.layout
+        
+        layout.operator("anim.keying_set_import", text="Import From File")
+
 class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel):
     bl_label = "Active Keying Set"
 
@@ -198,6 +207,36 @@
 #  XXX, move operator to op/ dir
 
 
+class ANIM_OT_keying_set_import(bpy.types.Operator):
+    "Import Keying Set from a python script."
+    bl_idname = "anim.keying_set_import"
+    bl_label = "Import Keying Set from File"
+
+    filepath = bpy.props.StringProperty(name="File Path", description="Filepath to read file from.")
+    filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
+    filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'})
+    filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
+
+    def execute(self, context):
+        if not self.filepath:
+            raise Exception("Filepath not set.")
+        
+        f = open(self.filepath, "r")
+        if not f:
+            raise Exception("Could not open file.")
+        
+        # lazy way of loading and running this file...
+        exec(compile(f.read(), self.filepath, 'exec'))
+        
+        f.close()
+
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        wm = context.window_manager
+        wm.fileselect_add(self)
+        return {'RUNNING_MODAL'}
+
 class ANIM_OT_keying_set_export(bpy.types.Operator):
     "Export Keying Set to a python script."
     bl_idname = "anim.keying_set_export"




More information about the Bf-blender-cvs mailing list