From e8e36e184bf3c3f21036a4f6099cbabfc3470ceb Mon Sep 17 00:00:00 2001
From: Bastien Montagne <montagne29@wanadoo.fr>
Date: Sun, 27 May 2012 09:38:39 +0000
Subject: [PATCH] Turned out only raw exporter had same bug...

Also, only calc_tessface() when needed, and use ExportHelper for RAW!
---
 io_mesh_ply/export_ply.py |  3 ++-
 io_mesh_raw/__init__.py   | 22 +++++-----------------
 io_mesh_raw/export_raw.py |  2 ++
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/io_mesh_ply/export_ply.py b/io_mesh_ply/export_ply.py
index 0dd0b39d0..2b58186b3 100644
--- a/io_mesh_ply/export_ply.py
+++ b/io_mesh_ply/export_ply.py
@@ -66,7 +66,8 @@ def save(operator,
     # mesh.transform(obj.matrix_world) # XXX
 
     # Be sure tessface & co are available!
-    mesh.calc_tessface()
+    if not mesh.tessfaces and mesh.polygons:
+        mesh.calc_tessface()
 
     has_uv = (len(mesh.tessface_uv_textures) > 0)
     has_uv_vertex = (len(mesh.sticky) > 0)
diff --git a/io_mesh_raw/__init__.py b/io_mesh_raw/__init__.py
index d677e4533..079248d74 100644
--- a/io_mesh_raw/__init__.py
+++ b/io_mesh_raw/__init__.py
@@ -43,6 +43,7 @@ else:
     import bpy
 
 from bpy.props import StringProperty, BoolProperty
+from bpy_extras.io_utils import ExportHelper
 
 
 class RawImporter(bpy.types.Operator):
@@ -67,20 +68,14 @@ class RawImporter(bpy.types.Operator):
         return {'RUNNING_MODAL'}
 
 
-class RawExporter(bpy.types.Operator):
+class RawExporter(bpy.types.Operator, ExportHelper):
     '''Save Raw triangle mesh data'''
     bl_idname = "export_mesh.raw"
     bl_label = "Export RAW"
 
-    filepath = StringProperty(
-            subtype='FILE_PATH',
-            )
-    check_existing = BoolProperty(
-            name="Check Existing",
-            description="Check and warn on overwriting existing files",
-            default=True,
-            options={'HIDDEN'},
-            )
+    filename_ext = ".raw"
+    filter_glob = StringProperty(default="*.raw", options={'HIDDEN'})
+
     apply_modifiers = BoolProperty(
             name="Apply Modifiers",
             description="Use transformed mesh data from each object",
@@ -101,13 +96,6 @@ class RawExporter(bpy.types.Operator):
 
         return {'FINISHED'}
 
-    def invoke(self, context, event):
-        if not self.filepath:
-            self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".raw")
-        wm = context.window_manager
-        wm.fileselect_add(self)
-        return {'RUNNING_MODAL'}
-
 
 def menu_import(self, context):
     self.layout.operator(RawImporter.bl_idname, text="Raw Faces (.raw)")
diff --git a/io_mesh_raw/export_raw.py b/io_mesh_raw/export_raw.py
index a18015185..b5c5ef36f 100644
--- a/io_mesh_raw/export_raw.py
+++ b/io_mesh_raw/export_raw.py
@@ -75,6 +75,8 @@ def write(filepath,
             is_tmp_mesh = True
         else:
             me = obj.data
+            if not me.tessfaces and me.polygons:
+                me.calc_tessface()
             is_tmp_mesh = False
 
         if me is not None:
-- 
GitLab