From d9a3c2d5c272c9b9eeeb09d3343430d294401cda Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Tue, 24 Feb 2026 12:44:34 -0800 Subject: [PATCH] alignment api cleanup updates some documentation removes some dead code --- .../api/alignment/clear_layout_segments.py | 3 +- .../api/alignment/create_as_polyline.py | 85 ------------------- 2 files changed, 1 insertion(+), 87 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/clear_layout_segments.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/clear_layout_segments.py index 4c534fea33..79560f46d9 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/clear_layout_segments.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/clear_layout_segments.py @@ -38,8 +38,7 @@ def _is_zero_length_segment(segment: entity_instance) -> bool: def clear_layout_segments(file: ifcopenshell.file, layout: entity_instance) -> None: """ Clear all segments from a layout while preserving the layout entity - and zero-length terminator. After calling this, use - layout_horizontal_alignment_by_pi_method() to add new segments. + and zero-length terminator. This function removes: - All real (non-zero-length) IfcAlignmentSegment entities from the layout diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/create_as_polyline.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/create_as_polyline.py index 4988a31920..a1d345ff3a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/create_as_polyline.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/create_as_polyline.py @@ -30,91 +30,6 @@ from ifcopenshell.api.alignment._create_polyline_representation import ( ) -def _create_layout(file: ifcopenshell.file, alignment: entity_instance, points: Sequence[entity_instance]): - """ - I don't believe it is required for polylines, but the validation serivce gives an error if the alignment doesn't have a layout - """ - include_vertical = False if points[0].Dim == 2 else True - - alignment_layouts = [] - - alignment_layouts.append(file.createIfcAlignmentHorizontal(GlobalId=ifcopenshell.guid.new())) - - if include_vertical: - alignment_layouts.append(file.createIfcAlignmentVertical(GlobalId=ifcopenshell.guid.new())) - - ifcopenshell.api.nest.assign_object(file, related_objects=alignment_layouts, relating_object=alignment) - - start_dist_along = 0.0 - for p1, p2 in zip(points, points[1:]): - x1, y1, z1 = p1.Coordinates - x2, y2, z2 = p2.Coordinates - dir = math.atan2(y2 - y1, x2 - x1) - gradient = (z2 - z1) / (x2 - x1) - length = math.sqrt(math.pow((x2 - x1), 2.0) + math.pow((y2 - y1), 2.0)) - - hsegment = file.createIfcAlignmentSegment( - ifcopenshell.guid.new(), - DesignParameters=file.createIfcAlignmentHorizontalSegment( - StartPoint=p1, - StartDirection=dir, - StartRadiusOfCurvature=0.0, - EndRadiusOfCurvature=0.0, - SegmentLength=length, - PredefinedType="LINE", - ), - ) - - ifcopenshell.api.nest.assign_object(file, related_objects=[hsegment], relating_object=alignment_layouts[0]) - - if include_vertical: - vsegment = file.createIfcAlignmentSegment( - ifcopenshell.guid.new(), - DesignParameters=file.createIfcAlignmentVerticalSegment( - StartDistAlong=start_dist_along, - HorizontalLength=length, - StartHeight=z1, - StartGradient=gradient, - EndGradient=gradient, - PredefinedType="CONSTANTGRADIENT", - ), - ) - - ifcopenshell.api.nest.assign_object(file, related_objects=[vsegment], relating_object=alignment_layouts[1]) - - start_dist_along += length - - # zero length segment - hsegment = file.createIfcAlignmentSegment( - ifcopenshell.guid.new(), - DesignParameters=file.createIfcAlignmentHorizontalSegment( - StartPoint=points[-1], - StartDirection=dir, - StartRadiusOfCurvature=0.0, - EndRadiusOfCurvature=0.0, - SegmentLength=0.0, - PredefinedType="LINE", - ), - ) - - ifcopenshell.api.nest.assign_object(file, related_objects=[hsegment], relating_object=alignment_layouts[0]) - - if include_vertical: - vsegment = file.createIfcAlignmentSegment( - ifcopenshell.guid.new(), - DesignParameters=file.createIfcAlignmentVerticalSegment( - StartDistAlong=start_dist_along, - HorizontalLength=0.0, - StartHeight=points[-1].Coordinates[-1], - StartGradient=gradient, - EndGradient=gradient, - PredefinedType="CONSTANTGRADIENT", - ), - ) - - ifcopenshell.api.nest.assign_object(file, related_objects=[vsegment], relating_object=alignment_layouts[1]) - - def create_as_polyline( file: ifcopenshell.file, name: str,