[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31684] trunk/blender/release/scripts: use mix-in classes for import export operators, these define the filepath property and invoke function at the moment.
Campbell Barton
ideasman42 at gmail.com
Wed Sep 1 04:25:50 CEST 2010
Revision: 31684
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31684
Author: campbellbarton
Date: 2010-09-01 04:25:49 +0200 (Wed, 01 Sep 2010)
Log Message:
-----------
use mix-in classes for import export operators, these define the filepath property and invoke function at the moment.
Modified Paths:
--------------
trunk/blender/release/scripts/io/export_3ds.py
trunk/blender/release/scripts/io/export_fbx.py
trunk/blender/release/scripts/io/export_mdd.py
trunk/blender/release/scripts/io/export_obj.py
trunk/blender/release/scripts/io/export_ply.py
trunk/blender/release/scripts/io/export_x3d.py
trunk/blender/release/scripts/io/import_anim_bvh.py
trunk/blender/release/scripts/io/import_scene_3ds.py
trunk/blender/release/scripts/io/import_scene_obj.py
trunk/blender/release/scripts/io/import_shape_mdd.py
trunk/blender/release/scripts/ui/space_filebrowser.py
Added Paths:
-----------
trunk/blender/release/scripts/modules/io_utils.py
Modified: trunk/blender/release/scripts/io/export_3ds.py
===================================================================
--- trunk/blender/release/scripts/io/export_3ds.py 2010-08-31 23:55:41 UTC (rev 31683)
+++ trunk/blender/release/scripts/io/export_3ds.py 2010-09-01 02:25:49 UTC (rev 31684)
@@ -1107,36 +1107,29 @@
#primary.dump()
-# # write('/test_b.3ds')
from bpy.props import *
-class Export3DS(bpy.types.Operator):
+from io_utils import ExportHelper
+
+
+class Export3DS(bpy.types.Operator, ExportHelper):
'''Export to 3DS file format (.3ds)'''
bl_idname = "export.autodesk_3ds"
bl_label = 'Export 3DS'
+
+ filename_ext = ".3ds"
- 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")
+ filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
write(filepath, context)
return {'FINISHED'}
- def invoke(self, context, event):
- 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'}
-
-
# Add to a menu
def menu_func(self, context):
self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)")
Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py 2010-08-31 23:55:41 UTC (rev 31683)
+++ trunk/blender/release/scripts/io/export_fbx.py 2010-09-01 02:25:49 UTC (rev 31684)
@@ -3319,19 +3319,21 @@
# GLOBALS.clear()
+
from bpy.props import *
-class ExportFBX(bpy.types.Operator):
+from io_utils import ExportHelper
+
+
+class ExportFBX(bpy.types.Operator, ExportHelper):
'''Selection to an ASCII Autodesk FBX'''
bl_idname = "export.fbx"
bl_label = "Export FBX"
+
+ filename_ext = ".fbx"
# 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 FBX file", maxlen= 1024, default="")
- check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
-
EXP_OBS_SELECTED = BoolProperty(name="Selected Objects", description="Export selected objects on visible layers", default=True)
# EXP_OBS_SCENE = BoolProperty(name="Scene Objects", description="Export all objects in this scene", default=True)
TX_SCALE = FloatProperty(name="Scale", description="Scale all data, (Note! some imports dont support scaled armatures)", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)
@@ -3368,7 +3370,7 @@
raise Exception("filepath not set")
filepath = self.properties.filepath
- filepath = bpy.path.ensure_ext(filepath, ".fbx")
+ filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
GLOBAL_MATRIX = mtx4_identity
GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self.properties.TX_SCALE
@@ -3401,17 +3403,7 @@
return {'FINISHED'}
- def invoke(self, context, event):
- 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'}
-
-
-
-
# if __name__ == "__main__":
# bpy.ops.EXPORT_OT_ply(filepath="/tmp/test.ply")
Modified: trunk/blender/release/scripts/io/export_mdd.py
===================================================================
--- trunk/blender/release/scripts/io/export_mdd.py 2010-08-31 23:55:41 UTC (rev 31683)
+++ trunk/blender/release/scripts/io/export_mdd.py 2010-09-01 02:25:49 UTC (rev 31684)
@@ -143,12 +143,15 @@
sce.set_frame(orig_frame)
from bpy.props import *
+from io_utils import ExportHelper
-class ExportMDD(bpy.types.Operator):
+class ExportMDD(bpy.types.Operator, ExportHelper):
'''Animated mesh to MDD vertex keyframe file'''
bl_idname = "export.mdd"
bl_label = "Export MDD"
+
+ filename_ext = ".mdd"
# get first scene to get min and max properties for frames, fps
@@ -159,8 +162,6 @@
# 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 MDD file", maxlen=1024)
- check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25)
frame_start = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1)
frame_end = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250)
@@ -172,7 +173,7 @@
def execute(self, context):
filepath = self.properties.filepath
- filepath = bpy.path.ensure_ext(filepath, ".mdd")
+ filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
write(filepath,
context.scene,
@@ -184,15 +185,7 @@
return {'FINISHED'}
- def invoke(self, context, event):
- 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):
self.layout.operator(ExportMDD.bl_idname, text="Lightwave Point Cache (.mdd)")
Modified: trunk/blender/release/scripts/io/export_obj.py
===================================================================
--- trunk/blender/release/scripts/io/export_obj.py 2010-08-31 23:55:41 UTC (rev 31683)
+++ trunk/blender/release/scripts/io/export_obj.py 2010-09-01 02:25:49 UTC (rev 31684)
@@ -854,19 +854,20 @@
'''
from bpy.props import *
+from io_utils import ExportHelper
-class ExportOBJ(bpy.types.Operator):
+
+class ExportOBJ(bpy.types.Operator, ExportHelper):
'''Save a Wavefront OBJ File'''
bl_idname = "export.obj"
bl_label = 'Export OBJ'
+
+ filename_ext = ".obj"
# 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 OBJ file", maxlen= 1024, default= "", subtype='FILE_PATH')
- check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
-
# context group
use_selection = BoolProperty(name="Selection Only", description="Export selected objects only", default= False)
use_all_scenes = BoolProperty(name="All Scenes", description="", default= False)
@@ -897,7 +898,7 @@
def execute(self, context):
filepath = self.properties.filepath
- filepath = bpy.path.ensure_ext(filepath, ".obj")
+ filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
write(filepath, context,
EXPORT_TRI=self.properties.use_triangles,
@@ -921,15 +922,7 @@
return {'FINISHED'}
- def invoke(self, context, event):
- 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):
self.layout.operator(ExportOBJ.bl_idname, text="Wavefront (.obj)")
Modified: trunk/blender/release/scripts/io/export_ply.py
===================================================================
--- trunk/blender/release/scripts/io/export_ply.py 2010-08-31 23:55:41 UTC (rev 31683)
+++ trunk/blender/release/scripts/io/export_ply.py 2010-09-01 02:25:49 UTC (rev 31684)
@@ -257,19 +257,19 @@
"""
from bpy.props import *
+from io_utils import ExportHelper
-class ExportPLY(bpy.types.Operator):
+class ExportPLY(bpy.types.Operator, ExportHelper):
'''Export a single object as a stanford PLY with normals, colours and texture coordinates.'''
bl_idname = "export.ply"
bl_label = "Export PLY"
+
+ filename_ext = ".ply"
# 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 PLY file", maxlen=1024, default="")
- check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default=True)
use_normals = BoolProperty(name="Normals", description="Export Normals for smooth and hard shaded faces", default=True)
use_uvs = BoolProperty(name="UVs", description="Exort the active UV layer", default=True)
@@ -281,7 +281,7 @@
def execute(self, context):
filepath = self.properties.filepath
- filepath = bpy.path.ensure_ext(filepath, ".ply")
+ filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
write(filepath, context.scene, context.active_object,\
EXPORT_APPLY_MODIFIERS=self.properties.use_modifiers,
@@ -292,14 +292,6 @@
return {'FINISHED'}
- def invoke(self, context, event):
- import os
- if not self.properties.is_property_set("filepath"):
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list