A few more fixes for zero length segments

This commit is contained in:
Richard Brice
2025-07-25 17:31:50 -07:00
parent ed0e825283
commit bb56882879
2 changed files with 7 additions and 2 deletions
@@ -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)
@@ -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