diff options
Diffstat (limited to 'release/scripts/io/export_ply.py')
-rw-r--r-- | release/scripts/io/export_ply.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 92d4f2ff914..0b936bdceb2 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -99,10 +99,11 @@ def write(filename, scene, ob, \ Window.WaitCursor(1) """ + bpy.ops.object.mode_set(mode='OBJECT') #mesh = BPyMesh.getMeshFromObject(ob, None, EXPORT_APPLY_MODIFIERS, False, scn) # XXX if EXPORT_APPLY_MODIFIERS: - mesh = ob.create_mesh(True, 'PREVIEW') + mesh = ob.create_mesh(scene, True, 'PREVIEW') else: mesh = ob.data @@ -110,7 +111,7 @@ def write(filename, scene, ob, \ raise ("Error, could not get mesh data from active object") return - # mesh.transform(ob.matrixWorld) # XXX + # mesh.transform(ob.matrix_world) # XXX faceUV = (len(mesh.uv_textures) > 0) vertexUV = (len(mesh.sticky) > 0) @@ -202,7 +203,7 @@ def write(filename, scene, ob, \ file.write('ply\n') file.write('format ascii 1.0\n') - file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (bpy.app.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1])) + file.write('comment Created by Blender %s - www.blender.org, source file: %s\n' % (bpy.app.version_string, bpy.data.filepath.split('/')[-1].split('\\')[-1])) file.write('element vertex %d\n' % len(ply_verts)) @@ -210,13 +211,10 @@ def write(filename, scene, ob, \ file.write('property float y\n') file.write('property float z\n') - # XXX - """ if EXPORT_NORMALS: file.write('property float nx\n') file.write('property float ny\n') file.write('property float nz\n') - """ if EXPORT_UV: file.write('property float s\n') file.write('property float t\n') @@ -231,10 +229,8 @@ def write(filename, scene, ob, \ for i, v in enumerate(ply_verts): file.write('%.6f %.6f %.6f ' % tuple(mesh_verts[v[0]].co)) # co - """ if EXPORT_NORMALS: file.write('%.6f %.6f %.6f ' % v[1]) # no - """ if EXPORT_UV: file.write('%.6f %.6f ' % v[2]) # uv if EXPORT_COLORS: @@ -271,7 +267,7 @@ class ExportPLY(bpy.types.Operator): # to the class instance from the operator settings before calling. - path = StringProperty(name="File Path", description="File path used for exporting the PLY file", maxlen=1024, default="") + 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) @@ -284,10 +280,10 @@ class ExportPLY(bpy.types.Operator): def execute(self, context): # print("Selected: " + context.active_object.name) - if not self.properties.path: + if not self.properties.filepath: raise Exception("filename not set") - write(self.properties.path, context.scene, context.active_object,\ + write(self.properties.filepath, context.scene, context.active_object,\ EXPORT_APPLY_MODIFIERS=self.properties.use_modifiers, EXPORT_NORMALS=self.properties.use_normals, EXPORT_UV=self.properties.use_uvs, @@ -314,8 +310,9 @@ class ExportPLY(bpy.types.Operator): def menu_func(self, context): - default_path = bpy.data.filename.replace(".blend", ".ply") - self.layout.operator(ExportPLY.bl_idname, text="Stanford (.ply)").path = default_path + import os + default_path = os.path.splitext(bpy.data.filepath)[0] + ".ply" + self.layout.operator(ExportPLY.bl_idname, text="Stanford (.ply)").filepath = default_path def register(): |