From 845c077891e723ed9cb662a419b3f2847f2a1644 Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Wed, 3 Aug 2011 05:33:14 +0000
Subject: [PATCH] move axis conversion check into blenders parent helper
 function.

---
 io_scene_3ds/__init__.py   |  7 -------
 io_scene_fbx/__init__.py   | 14 ++++----------
 io_scene_map/__init__.py   |  5 -----
 io_scene_obj/__init__.py   | 10 +---------
 io_scene_obj/export_obj.py | 15 ++++++++-------
 io_scene_x3d/__init__.py   |  7 -------
 6 files changed, 13 insertions(+), 45 deletions(-)

diff --git a/io_scene_3ds/__init__.py b/io_scene_3ds/__init__.py
index 08798f659..ef3ad111a 100644
--- a/io_scene_3ds/__init__.py
+++ b/io_scene_3ds/__init__.py
@@ -47,7 +47,6 @@ from bpy.props import StringProperty, FloatProperty, BoolProperty, EnumProperty
 from bpy_extras.io_utils import (ImportHelper,
                                  ExportHelper,
                                  axis_conversion,
-                                 axis_conversion_ensure,
                                  )
 
 
@@ -104,9 +103,6 @@ class Import3DS(bpy.types.Operator, ImportHelper):
             default='Z',
             )
 
-    def check(self, context):
-        return axis_conversion_ensure(self, "axis_forward", "axis_up")
-
     def execute(self, context):
         from . import import_3ds
 
@@ -164,9 +160,6 @@ class Export3DS(bpy.types.Operator, ExportHelper):
             default='Z',
             )
 
-    def check(self, context):
-        return axis_conversion_ensure(self, "axis_forward", "axis_up")
-
     def execute(self, context):
         from . import export_3ds
 
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index d901fe88d..01332a6b5 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -27,8 +27,8 @@ bl_info = {
     "description": ("Export FBX meshes, UV's, vertex colors, materials, "
                     "textures, cameras, lamps and actions"),
     "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
-        "Scripts/Import-Export/Autodesk_FBX",
+    "wiki_url": ("http://wiki.blender.org/index.php/Extensions:2.5/Py/"
+                 "Scripts/Import-Export/Autodesk_FBX"),
     "tracker_url": "",
     "support": 'OFFICIAL',
     "category": "Import-Export"}
@@ -46,7 +46,6 @@ from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
 from bpy_extras.io_utils import (ExportHelper,
                                  path_reference_mode,
                                  axis_conversion,
-                                 axis_conversion_ensure,
                                  )
 
 
@@ -226,14 +225,9 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
         return self.batch_mode == 'OFF'
 
     def check(self, context):
+        is_def_change = super().check(context)
         is_xna_change = self._validate_xna_options()
-        is_axis_change = axis_conversion_ensure(self,
-                                                "axis_forward",
-                                                "axis_up")
-        if is_xna_change or is_axis_change:
-            return True
-        else:
-            return False
+        return (is_xna_change or is_def_change)
 
     def execute(self, context):
         from mathutils import Matrix
diff --git a/io_scene_map/__init__.py b/io_scene_map/__init__.py
index 51e889d9b..77e85d5f3 100644
--- a/io_scene_map/__init__.py
+++ b/io_scene_map/__init__.py
@@ -83,11 +83,6 @@ class ExportMAP(bpy.types.Operator, ExportHelper):
             default='0 0 0 1 1 0 0 0',
             )
 
-    '''
-    def check(self, context):
-        return axis_conversion_ensure(self, "axis_forward", "axis_up")
-    '''
-
     def execute(self, context):
         # import math
         # from mathutils import Matrix
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 74a302937..20216df30 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -51,7 +51,6 @@ from bpy_extras.io_utils import (ExportHelper,
                                  ImportHelper,
                                  path_reference_mode,
                                  axis_conversion,
-                                 axis_conversion_ensure,
                                  )
 
 
@@ -145,9 +144,6 @@ class ImportOBJ(bpy.types.Operator, ImportHelper):
             default='Y',
             )
 
-    def check(self, context):
-        return axis_conversion_ensure(self, "axis_forward", "axis_up")
-
     def execute(self, context):
         # print("Selected: " + context.active_object.name)
         from . import import_obj
@@ -213,9 +209,6 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
             options={'HIDDEN'},
             )
 
-    # List of operator properties, the attributes will be assigned
-    # to the class instance from the operator settings before calling.
-
     # context group
     use_selection = BoolProperty(
             name="Selection Only",
@@ -339,8 +332,7 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
 
     path_mode = path_reference_mode
 
-    def check(self, context):
-        return axis_conversion_ensure(self, "axis_forward", "axis_up")
+    check_extension = True
 
     def execute(self, context):
         from . import export_obj
diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py
index b043ec6de..a8534b676 100644
--- a/io_scene_obj/export_obj.py
+++ b/io_scene_obj/export_obj.py
@@ -34,12 +34,13 @@ def name_compat(name):
 
 
 def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
+    from mathutils import Color
 
     world = scene.world
     if world:
-        worldAmb = world.ambient_color[:]
+        world_amb = world.ambient_color
     else:
-        worldAmb = 0.0, 0.0, 0.0
+        world_amb = Color((0.0, 0.0, 0.0))
 
     source_dir = bpy.data.filepath
     dest_dir = os.path.dirname(filepath)
@@ -69,9 +70,9 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
             file.write('Ns %.6f\n' % tspec)
             del tspec
 
-            file.write('Ka %.6f %.6f %.6f\n' % tuple(c * mat.ambient for c in worldAmb))  # Ambient, uses mirror colour,
-            file.write('Kd %.6f %.6f %.6f\n' % tuple(c * mat.diffuse_intensity for c in mat.diffuse_color))  # Diffuse
-            file.write('Ks %.6f %.6f %.6f\n' % tuple(c * mat.specular_intensity for c in mat.specular_color))  # Specular
+            file.write('Ka %.6f %.6f %.6f\n' % (mat.ambient * world_amb)[:])  # Ambient, uses mirror colour,
+            file.write('Kd %.6f %.6f %.6f\n' % (mat.diffuse_intensity * mat.diffuse_color)[:])  # Diffuse
+            file.write('Ks %.6f %.6f %.6f\n' % (mat.specular_intensity * mat.specular_color)[:])  # Specular
             if hasattr(mat, "ior"):
                 file.write('Ni %.6f\n' % mat.ior)  # Refraction index
             else:
@@ -89,7 +90,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
         else:
             #write a dummy material here?
             file.write('Ns 0\n')
-            file.write('Ka %.6f %.6f %.6f\n' % tuple(c for c in worldAmb))  # Ambient, uses mirror colour,
+            file.write('Ka %.6f %.6f %.6f\n' % world_amb[:])  # Ambient, uses mirror colour,
             file.write('Kd 0.8 0.8 0.8\n')
             file.write('Ks 0.8 0.8 0.8\n')
             file.write('d 1\n')  # No alpha
@@ -413,7 +414,7 @@ def write_file(filepath, objects, scene,
 #               except: faces.sort(lambda a,b: cmp(a.use_smooth, b.use_smooth))
 
             # Set the default mat to no material and no image.
-            contextMat = 0, 0  # Can never be this, so we will label a new material teh first chance we get.
+            contextMat = 0, 0  # Can never be this, so we will label a new material the first chance we get.
             contextSmooth = None  # Will either be true or false,  set bad to force initialization switch.
 
             if EXPORT_BLEN_OBS or EXPORT_GROUP_BY_OB:
diff --git a/io_scene_x3d/__init__.py b/io_scene_x3d/__init__.py
index 1d0841e00..1f2425f77 100644
--- a/io_scene_x3d/__init__.py
+++ b/io_scene_x3d/__init__.py
@@ -44,7 +44,6 @@ from bpy.props import StringProperty, BoolProperty, EnumProperty
 from bpy_extras.io_utils import (ImportHelper,
                                  ExportHelper,
                                  axis_conversion,
-                                 axis_conversion_ensure,
                                  path_reference_mode,
                                  )
 
@@ -81,9 +80,6 @@ class ImportX3D(bpy.types.Operator, ImportHelper):
             default='Y',
             )
 
-    def check(self, context):
-        return axis_conversion_ensure(self, "axis_forward", "axis_up")
-
     def execute(self, context):
         from . import import_x3d
 
@@ -136,9 +132,6 @@ class ExportX3D(bpy.types.Operator, ExportHelper):
 
     path_mode = path_reference_mode
 
-    def check(self, context):
-        return axis_conversion_ensure(self, "axis_forward", "axis_up")
-
     def execute(self, context):
         from . import export_x3d
 
-- 
GitLab