From bb56882879a26d7459525c15a6b4974c8d73314b Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:31:50 -0700 Subject: [PATCH] A few more fixes for zero length segments --- .../ifcopenshell/api/alignment/_add_zero_length_segment.py | 2 +- .../ifcopenshell/api/alignment/add_zero_length_segment.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py index 32d9d2b30c..f5face824c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_zero_length_segment.py @@ -50,5 +50,5 @@ def _add_zero_length_segment(file: ifcopenshell.file, layout: entity_instance) - segment = layout.IsNestedBy[0].RelatedObjects[-1] alignment = ifcopenshell.api.alignment.get_alignment(layout) station = ifcopenshell.api.alignment.get_alignment_station(file,alignment) - name = f"{_get_segment_start_point_label(segment,None)} {ifcopenshell.util.alignment.station_as_string(file,station)}" + name = f"{_get_segment_start_point_label(segment,None)} ({ifcopenshell.util.alignment.station_as_string(file,station)})" ifcopenshell.api.alignment.add_stationing_referent(file, segment, 0.0, station, name=name) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py index 00dc3b8fd9..b47ab9ad33 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/add_zero_length_segment.py @@ -40,6 +40,11 @@ def add_zero_length_segment(file: ifcopenshell.file, layout: entity_instance, in :param include_referent: If True, an IfcReferent representing the ending point of the layout is included for IfcLinearElement layouts (i.e. business logic) :return: True if segment is added """ + + # These are valid curve types for alignment, but don't have the zero-length segment + if layout.is_a("IfcOffsetCurveByDistances") or layout.is_a("IfcPolyline") or layout.is_a("IfcIndexedPolyCurve"): + return + expected_types = ["IfcAlignmentHorizontal", "IfcAlignmentVertical", "IfcAlignmentCant","IfcCompositeCurve","IfcGradientCurve","IfcSegmentedReferenceCurve"] if not layout.is_a() in expected_types: raise TypeError( @@ -202,7 +207,7 @@ def add_zero_length_segment(file: ifcopenshell.file, layout: entity_instance, in if include_referent: alignment = ifcopenshell.api.alignment.get_alignment(layout) station = ifcopenshell.api.alignment.get_alignment_station(file,alignment) - name = f"{_get_segment_start_point_label(zero_length_curve_segment,None)} {ifcopenshell.util.alignment.station_as_string(file,station)}" + name = f"{_get_segment_start_point_label(zero_length_curve_segment,None)} ({ifcopenshell.util.alignment.station_as_string(file,station)})" ifcopenshell.api.alignment.add_stationing_referent(file, zero_length_curve_segment, 0.0, station, name=name) return True \ No newline at end of file