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.
This commit is contained in:
parent
3030e2d1cb
commit
cf365275c2
Notes:
blender-bot
2023-02-14 19:57:37 +01:00
Referenced by issue blender/blender-addons#44089, XYZ translation to .stl
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue