From eba3ced5fe870c2ff3511e54c18e8694a65eaded Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Mon, 1 Sep 2025 15:31:58 -0700 Subject: [PATCH] Fixes angle unit conversion when creating horizontal alignment from PI --- .../alignment/layout_horizontal_alignment_by_pi_method.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py index 0be11c95d5..3e0ec40b67 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/layout_horizontal_alignment_by_pi_method.py @@ -40,6 +40,8 @@ def layout_horizontal_alignment_by_pi_method( if not (len(hpoints) - 2 == len(radii)): raise ValueError("radii should have two fewer elements that hpoints") + angle_unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file, "PLANEANGLEUNIT") + xBT, yBT = hpoints[0] xPI, yPI = hpoints[1] @@ -84,7 +86,7 @@ def layout_horizontal_alignment_by_pi_method( StartTag=None, EndTag=None, StartPoint=pt, - StartDirection=angleBT, + StartDirection=angleBT / angle_unit_scale, StartRadiusOfCurvature=0.0, EndRadiusOfCurvature=0.0, SegmentLength=tangent_run, @@ -102,7 +104,7 @@ def layout_horizontal_alignment_by_pi_method( StartTag=None, EndTag=None, StartPoint=pc, - StartDirection=angleBT, + StartDirection=angleBT / angle_unit_scale, StartRadiusOfCurvature=float(radius), EndRadiusOfCurvature=float(radius), SegmentLength=lc, @@ -130,7 +132,7 @@ def layout_horizontal_alignment_by_pi_method( StartTag=None, EndTag=None, StartPoint=pt, - StartDirection=angleBT, + StartDirection=angleBT / angle_unit_scale, StartRadiusOfCurvature=0.0, EndRadiusOfCurvature=0.0, SegmentLength=tangent_run,