[Bf-blender-cvs] [edad3f9] master: Py IO utils: Add helper class to handle orientation (axes).

Bastien Montagne noreply at git.blender.org
Wed Jan 14 13:10:29 CET 2015


Commit: edad3f93f6da549456ffe8711336d34c7819dbe7
Author: Bastien Montagne
Date:   Wed Jan 14 13:00:52 2015 +0100
Branches: master
https://developer.blender.org/rBedad3f93f6da549456ffe8711336d34c7819dbe7

Py IO utils: Add helper class to handle orientation (axes).

Also 'fix' T43243, since we can easily add a common better behavior now
when both axis settings are incompatible, by systematically changing
the other axis.

Will update 'main' addons in next commit, contrib ones I'll let to the authors
(old behavior is still possible anyway).

===================================================================

M	release/scripts/modules/bpy_extras/io_utils.py

===================================================================

diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py
index b1877a9..d1eb01a 100644
--- a/release/scripts/modules/bpy_extras/io_utils.py
+++ b/release/scripts/modules/bpy_extras/io_utils.py
@@ -21,6 +21,7 @@
 __all__ = (
     "ExportHelper",
     "ImportHelper",
+    "IOHelperOrientation",
     "axis_conversion",
     "axis_conversion_ensure",
     "create_derived_objects",
@@ -116,6 +117,40 @@ class ImportHelper:
         return _check_axis_conversion(self)
 
 
+class IOHelperOrientation:
+    def _update_axis_forward(self, context):
+        if self.axis_forward[-1] == self.axis_up[-1]:
+            self.axis_up = self.axis_up[0:-1] + 'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3]
+    axis_forward = EnumProperty(
+            name="Forward",
+            items=(('X', "X Forward", ""),
+                   ('Y', "Y Forward", ""),
+                   ('Z', "Z Forward", ""),
+                   ('-X', "-X Forward", ""),
+                   ('-Y', "-Y Forward", ""),
+                   ('-Z', "-Z Forward", ""),
+                   ),
+            default='-Z',
+            update=_update_axis_forward,
+            )
+
+    def _update_axis_up(self, context):
+        if self.axis_up[-1] == self.axis_forward[-1]:
+            self.axis_forward = self.axis_forward[0:-1] + 'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3]
+    axis_up = EnumProperty(
+            name="Up",
+            items=(('X', "X Up", ""),
+                   ('Y', "Y Up", ""),
+                   ('Z', "Z Up", ""),
+                   ('-X', "-X Up", ""),
+                   ('-Y', "-Y Up", ""),
+                   ('-Z', "-Z Up", ""),
+                   ),
+            default='Y',
+            update=_update_axis_up,
+            )
+
+
 # Axis conversion function, not pretty LUT
 # use lookup table to convert between any axis
 _axis_convert_matrix = (




More information about the Bf-blender-cvs mailing list