From f4b2e9b91d78b270f8741cec9b8770579d424f4a Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 10 Jun 2011 12:43:06 +0000 Subject: 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. --- release/scripts/startup/bl_ui/properties_scene.py | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'release/scripts/startup/bl_ui/properties_scene.py') diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 7725f661693..e2dc9de064f 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -76,6 +76,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): 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 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): 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 @@ class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel): # 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" -- cgit v1.2.3