[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21037] branches/blender2.5/blender/ release/io/export_ply.py: PLY export, use the file selector and added operator options
Campbell Barton
ideasman42 at gmail.com
Sat Jun 20 18:08:01 CEST 2009
Revision: 21037
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21037
Author: campbellbarton
Date: 2009-06-20 18:08:01 +0200 (Sat, 20 Jun 2009)
Log Message:
-----------
PLY export, use the file selector and added operator options
Modified Paths:
--------------
branches/blender2.5/blender/release/io/export_ply.py
Modified: branches/blender2.5/blender/release/io/export_ply.py
===================================================================
--- branches/blender2.5/blender/release/io/export_ply.py 2009-06-20 15:06:18 UTC (rev 21036)
+++ branches/blender2.5/blender/release/io/export_ply.py 2009-06-20 16:08:01 UTC (rev 21037)
@@ -50,7 +50,12 @@
def rvec3d(v): return round(v[0], 6), round(v[1], 6), round(v[2], 6)
def rvec2d(v): return round(v[0], 6), round(v[1], 6)
-def write(filename, ob, EXPORT_APPLY_MODIFIERS= True, EXPORT_NORMALS= True, EXPORT_UV= True, EXPORT_COLORS= True):
+def write(filename, scene, ob, \
+ EXPORT_APPLY_MODIFIERS= True,\
+ EXPORT_NORMALS= True,\
+ EXPORT_UV= True,\
+ EXPORT_COLORS= True\
+ ):
if not filename.lower().endswith('.ply'):
filename += '.ply'
@@ -72,7 +77,10 @@
"""
#mesh = BPyMesh.getMeshFromObject(ob, None, EXPORT_APPLY_MODIFIERS, False, scn) # XXX
- mesh = ob.data
+ if EXPORT_APPLY_MODIFIERS:
+ mesh = ob.create_render_mesh(scene)
+ else:
+ mesh = ob.data
if not mesh:
raise ("Error, could not get mesh data from active object")
@@ -219,20 +227,15 @@
file.close()
print("writing", filename, "done")
+ if EXPORT_APPLY_MODIFIERS:
+ bpy.data.remove_mesh(mesh)
+
# XXX
"""
if is_editmode:
Blender.Window.EditMode(1, '', 0)
"""
-"""
-def main():
- Blender.Window.FileSelector(file_callback, 'PLY Export', Blender.sys.makename(ext='.ply'))
-
-if __name__=='__main__':
- main()
-"""
-
class EXPORT_OT_ply(bpy.types.Operator):
'''
Operator documentatuon text, will be used for the operator tooltip and python docs.
@@ -243,7 +246,11 @@
# to the class instance from the operator settings before calling.
__props__ = [
- bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the PLY file", maxlen= 1024, default= "")
+ bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the PLY file", maxlen= 1024, default= ""),
+ bpy.props.BoolProperty(attr="use_modifiers", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True),
+ bpy.props.BoolProperty(attr="use_normals", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True),
+ bpy.props.BoolProperty(attr="use_uvs", name="Export UVs", description="Exort the active UV layer", default= True),
+ bpy.props.BoolProperty(attr="use_colors", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
]
def poll(self, context):
@@ -256,15 +263,19 @@
if not self.filename:
raise Exception("filename not set")
- write(self.filename, context.active_object)
+ write(self.filename, context.scene, context.active_object,\
+ EXPORT_APPLY_MODIFIERS = self.use_modifiers,
+ EXPORT_NORMALS = self.use_normals,
+ EXPORT_UV = self.use_uvs,
+ EXPORT_COLORS = self.use_colors,
+ )
return ('FINISHED',)
- def invoke(self, context, event):
- print("Invoke", context, event)
- # XXX file selector
- self.execute(context)
- return ('FINISHED',)
+ def invoke(self, context, event):
+ wm = context.manager
+ wm.add_fileselect(self.__operator__)
+ return ('RUNNING_MODAL',)
bpy.ops.add(EXPORT_OT_ply)
More information about the Bf-blender-cvs
mailing list