Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-06-20 20:08:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-06-20 20:08:01 +0400
commita42b436a98263749955c1cc85963c3fa0945f2c1 (patch)
treeeffd839b0c41cb851c7ba810aaaa9a12a0f8e2dc /release
parent823a7ce3d3b6cde3f99ed660f002c61502ba7736 (diff)
PLY export, use the file selector and added operator options
Diffstat (limited to 'release')
-rw-r--r--release/io/export_ply.py45
1 files changed, 28 insertions, 17 deletions
diff --git a/release/io/export_ply.py b/release/io/export_ply.py
index 6471b4b664a..ed983c2b169 100644
--- a/release/io/export_ply.py
+++ b/release/io/export_ply.py
@@ -50,7 +50,12 @@ Only one mesh can be exported at a time.
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 @@ def write(filename, ob, EXPORT_APPLY_MODIFIERS= True, EXPORT_NORMALS= True, EXPO
"""
#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 @@ def write(filename, ob, EXPORT_APPLY_MODIFIERS= True, EXPORT_NORMALS= True, EXPO
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 @@ class EXPORT_OT_ply(bpy.types.Operator):
# 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 @@ class EXPORT_OT_ply(bpy.types.Operator):
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)