From f662c0de0521d01ff546d46d5e9fb8a0f64c1c95 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Aug 2010 06:45:33 +0000 Subject: exporters now set the filepath in the invoke() method rather then the menu drawing function. --- release/scripts/io/export_3ds.py | 22 +++++++++++----------- release/scripts/io/export_fbx.py | 10 ++++++---- release/scripts/io/export_mdd.py | 11 ++++++----- release/scripts/io/export_obj.py | 10 ++++++---- release/scripts/io/export_ply.py | 11 ++++++----- release/scripts/io/export_x3d.py | 10 ++++++---- release/scripts/io/import_scene_obj.py | 3 +-- 7 files changed, 42 insertions(+), 35 deletions(-) (limited to 'release') diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index 2a8b43c4e84..83c9defd6ab 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -1114,13 +1114,13 @@ class Export3DS(bpy.types.Operator): bl_idname = "export.autodesk_3ds" bl_label = 'Export 3DS' - # List of operator properties, the attributes will be assigned - # to the class instance from the operator settings before calling. - - filepath = StringProperty(name="File Path", description="Filepath used for exporting the 3DS file", maxlen= 1024, default= "") check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'}) + @classmethod + def poll(cls, context): # Poll isnt working yet + return context.active_object != None + def execute(self, context): filepath = self.properties.filepath filepath = bpy.path.ensure_ext(filepath, ".3ds") @@ -1129,23 +1129,23 @@ class Export3DS(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - wm = context.manager - wm.add_fileselect(self) + import os + if not self.properties.is_property_set("filepath"): + self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + ".3ds" + + context.manager.add_fileselect(self) return {'RUNNING_MODAL'} - @classmethod - def poll(cls, context): # Poll isnt working yet - return context.active_object != None # Add to a menu def menu_func(self, context): - default_path = os.path.splitext(bpy.data.filepath)[0] + ".3ds" - self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)").filepath = default_path + self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)") def register(): bpy.types.INFO_MT_file_export.append(menu_func) + def unregister(): bpy.types.INFO_MT_file_export.remove(menu_func) diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index c040861941a..19d330f1ce2 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -3404,8 +3404,11 @@ class ExportFBX(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - wm = context.manager - wm.add_fileselect(self) + import os + if not self.properties.is_property_set("filepath"): + self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + ".fbx" + + context.manager.add_fileselect(self) return {'RUNNING_MODAL'} @@ -3439,8 +3442,7 @@ class ExportFBX(bpy.types.Operator): def menu_func(self, context): - default_path = os.path.splitext(bpy.data.filepath)[0] + ".fbx" - self.layout.operator(ExportFBX.bl_idname, text="Autodesk FBX (.fbx)").filepath = default_path + self.layout.operator(ExportFBX.bl_idname, text="Autodesk FBX (.fbx)") def register(): diff --git a/release/scripts/io/export_mdd.py b/release/scripts/io/export_mdd.py index 2d45e18ef77..a3e491a7bd5 100644 --- a/release/scripts/io/export_mdd.py +++ b/release/scripts/io/export_mdd.py @@ -185,15 +185,16 @@ class ExportMDD(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - wm = context.manager - wm.add_fileselect(self) + import os + if not self.properties.is_property_set("filepath"): + self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + ".mdd" + + context.manager.add_fileselect(self) return {'RUNNING_MODAL'} def menu_func(self, context): - import os - default_path = os.path.splitext(bpy.data.filepath)[0] + ".mdd" - self.layout.operator(ExportMDD.bl_idname, text="Lightwave Point Cache (.mdd)").filepath = default_path + self.layout.operator(ExportMDD.bl_idname, text="Lightwave Point Cache (.mdd)") def register(): diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index 5e951f06406..a25daedf1bb 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -960,14 +960,16 @@ class ExportOBJ(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - wm = context.manager - wm.add_fileselect(self) + import os + if not self.properties.is_property_set("filepath"): + self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + ".obj" + + context.manager.add_fileselect(self) return {'RUNNING_MODAL'} def menu_func(self, context): - default_path = os.path.splitext(bpy.data.filepath)[0] + ".obj" - self.layout.operator(ExportOBJ.bl_idname, text="Wavefront (.obj)").filepath = default_path + self.layout.operator(ExportOBJ.bl_idname, text="Wavefront (.obj)") def register(): diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index f4d7cae75a3..7ea3c72a662 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -293,8 +293,11 @@ class ExportPLY(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - wm = context.manager - wm.add_fileselect(self) + import os + if not self.properties.is_property_set("filepath"): + self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + ".ply" + + context.manager.add_fileselect(self) return {'RUNNING_MODAL'} def draw(self, context): @@ -310,9 +313,7 @@ class ExportPLY(bpy.types.Operator): def menu_func(self, context): - import os - default_path = os.path.splitext(bpy.data.filepath)[0] + ".ply" - self.layout.operator(ExportPLY.bl_idname, text="Stanford (.ply)").filepath = default_path + self.layout.operator(ExportPLY.bl_idname, text="Stanford (.ply)") def register(): diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 607f38be6f7..0d9c3efaec5 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -1205,14 +1205,16 @@ class ExportX3D(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - wm = context.manager - wm.add_fileselect(self) + import os + if not self.properties.is_property_set("filepath"): + self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + ".x3d" + + context.manager.add_fileselect(self) return {'RUNNING_MODAL'} def menu_func(self, context): - default_path = os.path.splitext(bpy.data.filepath)[0] + ".x3d" - self.layout.operator(ExportX3D.bl_idname, text="X3D Extensible 3D (.x3d)").filepath = default_path + self.layout.operator(ExportX3D.bl_idname, text="X3D Extensible 3D (.x3d)") def register(): diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index cbbeae9f7d5..3c976c4cf92 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -1596,8 +1596,7 @@ class IMPORT_OT_obj(bpy.types.Operator): return {'FINISHED'} def invoke(self, context, event): - wm = context.manager - wm.add_fileselect(self) + context.manager.add_fileselect(self) return {'RUNNING_MODAL'} -- cgit v1.2.3