Draft: array task panels: add workaround for Building US unit system

Fixes #26276.
This commit is contained in:
Roy-043
2025-12-18 20:56:35 +01:00
committed by Chris Hennes
parent 5297493a65
commit 4fe0dff1bc
3 changed files with 29 additions and 17 deletions

View File

@@ -45,6 +45,13 @@ from draftutils.translate import translate
bool(Draft_rc.__name__)
def _quantity(st):
# workaround for improper handling of plus sign
# in Building US unit system
# https://github.com/FreeCAD/FreeCAD/issues/11345
return U.Quantity(st.replace("+", "--")).Value
class TaskPanelCircularArray:
"""TaskPanel code for the CircularArray command.
@@ -266,7 +273,7 @@ class TaskPanelCircularArray:
"""Get the distance parameters from the widgets."""
r_d_str = self.form.spinbox_r_distance.text()
tan_d_str = self.form.spinbox_tan_distance.text()
return (U.Quantity(r_d_str).Value, U.Quantity(tan_d_str).Value)
return _quantity(r_d_str), _quantity(tan_d_str)
def get_number_symmetry(self):
"""Get the number and symmetry parameters from the widgets."""
@@ -279,9 +286,7 @@ class TaskPanelCircularArray:
c_x_str = self.form.input_c_x.text()
c_y_str = self.form.input_c_y.text()
c_z_str = self.form.input_c_z.text()
center = App.Vector(
U.Quantity(c_x_str).Value, U.Quantity(c_y_str).Value, U.Quantity(c_z_str).Value
)
center = App.Vector(_quantity(c_x_str), _quantity(c_y_str), _quantity(c_z_str))
return center
def get_axis(self):

View File

@@ -45,6 +45,13 @@ from draftutils.translate import translate
bool(Draft_rc.__name__)
def _quantity(st):
# workaround for improper handling of plus sign
# in Building US unit system
# https://github.com/FreeCAD/FreeCAD/issues/11345
return U.Quantity(st.replace("+", "--")).Value
class TaskPanelOrthoArray:
"""TaskPanel code for the OrthoArray command.
@@ -321,23 +328,18 @@ class TaskPanelOrthoArray:
v_x_x_str = self.form.input_X_x.text()
v_x_y_str = self.form.input_X_y.text()
v_x_z_str = self.form.input_X_z.text()
v_x = App.Vector(
U.Quantity(v_x_x_str).Value, U.Quantity(v_x_y_str).Value, U.Quantity(v_x_z_str).Value
)
v_x = App.Vector(_quantity(v_x_x_str), _quantity(v_x_y_str), _quantity(v_x_z_str))
v_y_x_str = self.form.input_Y_x.text()
v_y_y_str = self.form.input_Y_y.text()
v_y_z_str = self.form.input_Y_z.text()
v_y = App.Vector(
U.Quantity(v_y_x_str).Value, U.Quantity(v_y_y_str).Value, U.Quantity(v_y_z_str).Value
)
v_y = App.Vector(_quantity(v_y_x_str), _quantity(v_y_y_str), _quantity(v_y_z_str))
v_z_x_str = self.form.input_Z_x.text()
v_z_y_str = self.form.input_Z_y.text()
v_z_z_str = self.form.input_Z_z.text()
v_z = App.Vector(
U.Quantity(v_z_x_str).Value, U.Quantity(v_z_y_str).Value, U.Quantity(v_z_z_str).Value
)
v_z = App.Vector(_quantity(v_z_x_str), _quantity(v_z_y_str), _quantity(v_z_z_str))
return v_x, v_y, v_z
def reset_v(self, interval):

View File

@@ -45,6 +45,13 @@ from draftutils.translate import translate
bool(Draft_rc.__name__)
def _quantity(st):
# workaround for improper handling of plus sign
# in Building US unit system
# https://github.com/FreeCAD/FreeCAD/issues/11345
return U.Quantity(st.replace("+", "--")).Value
class TaskPanelPolarArray:
"""TaskPanel code for the PolarArray command.
@@ -241,7 +248,7 @@ class TaskPanelPolarArray:
number = self.form.spinbox_number.value()
angle_str = self.form.spinbox_angle.text()
angle = U.Quantity(angle_str).Value
angle = _quantity(angle_str)
return number, angle
def get_center(self):
@@ -249,9 +256,7 @@ class TaskPanelPolarArray:
c_x_str = self.form.input_c_x.text()
c_y_str = self.form.input_c_y.text()
c_z_str = self.form.input_c_z.text()
center = App.Vector(
U.Quantity(c_x_str).Value, U.Quantity(c_y_str).Value, U.Quantity(c_z_str).Value
)
center = App.Vector(_quantity(c_x_str), _quantity(c_y_str), _quantity(c_z_str))
return center
def reset_point(self):