diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-03-24 11:57:11 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-03-24 11:57:11 +0300 |
commit | cf365275c21e24f7653c3843b0d3f2a169101f2a (patch) | |
tree | 1456fd442ed49f3efddbdde9d22f74843c881657 /release/scripts/modules | |
parent | 3030e2d1cb1aaec554a409e44170b890d073c661 (diff) |
Fix T44089: All addons do not use same default for orientations.
Transformed 'OrientationHelper' class into 'orientation_helper_factory' function,
which returns an OrientationHelper customized class with specified default axes.
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bpy_extras/io_utils.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index 81de0d7c6f0..1dc6f5b2b2c 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -21,7 +21,7 @@ __all__ = ( "ExportHelper", "ImportHelper", - "OrientationHelper", + "orientation_helper_factory", "axis_conversion", "axis_conversion_ensure", "create_derived_objects", @@ -117,13 +117,14 @@ class ImportHelper: return _check_axis_conversion(self) -class OrientationHelper: +def orientation_helper_factory(name, axis_forward='Y', axis_up='Z'): + members = {} 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( + members['axis_forward'] = EnumProperty( name="Forward", items=(('X', "X Forward", ""), ('Y', "Y Forward", ""), @@ -132,7 +133,7 @@ class OrientationHelper: ('-Y', "-Y Forward", ""), ('-Z', "-Z Forward", ""), ), - default='-Z', + default=axis_forward, update=_update_axis_forward, ) @@ -140,7 +141,7 @@ class OrientationHelper: 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( + members['axis_up'] = EnumProperty( name="Up", items=(('X', "X Up", ""), ('Y', "Y Up", ""), @@ -149,10 +150,12 @@ class OrientationHelper: ('-Y', "-Y Up", ""), ('-Z', "-Z Up", ""), ), - default='Y', + default=axis_up, update=_update_axis_up, ) + return type(name, (object,), members) + # Axis conversion function, not pretty LUT # use lookup table to convert between any axis |