From 701635b81c1a25ef4cf160402a4cf1e6828961cc Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Wed, 25 Feb 2026 07:51:17 -0800 Subject: [PATCH] revises get_mapped_segments get_mapped_segments now looks for representations attached to alignment segments before using the more complex method of computing the index of segments in the composite curve. updates segment_vertices to use get_mapped_segments --- .../ifcopenshell/api/alignment/get_mapped_segments.py | 11 +++++++++++ .../ifcopenshell/api/alignment/segment_vertices.py | 9 +++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_mapped_segments.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_mapped_segments.py index 0b8a3b65b3..7e51a24543 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_mapped_segments.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_mapped_segments.py @@ -44,6 +44,17 @@ def get_mapped_segments(layout_segment: entity_instance) -> Sequence[entity_inst if not layout_segment.is_a(expected_type): raise TypeError(f"Expected to see type '{expected_type}', instead received '{layout_segment.is_a()}'.") + # if the representation is attached directly to the layout segment, just get the representation curve + representations = ifcopenshell.util.representation.get_representations_iter(layout_segment) + for representation in representations: + if representation.RepresentationIdentifier == "Axis" and representation.RepresentationType == "Segment": + if len(representation.Items) == 1: + return (representation.Items[0],None) + else: + return representation.Items + + # representation was not attached directly to the segment, so we have to find + # them from the composite curve layout = layout_segment.Nests[0].RelatingObject curve = ifcopenshell.api.alignment.get_layout_curve(layout) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/segment_vertices.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/segment_vertices.py index ae1fd86656..8e158eb599 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/segment_vertices.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/segment_vertices.py @@ -66,12 +66,9 @@ def segment_vertices(file: ifcopenshell.file, segment: entity_instance): # In the more common case, there is only one IfcCurveSegment geometric representation # and start_segment_curve and end_segment_curve are equal if segment_type == "IFCALIGNMENTSEGMENT": - representations = ifcopenshell.util.representation.get_representations_iter(segment) - for representation in representations: - if representation.RepresentationIdentifier == "Axis" and representation.RepresentationType == "Segment": - start_segment_curve = representation.Items[0] - end_segment_curve = representation.Items[-1] - break + segments = ifcopenshell.api.alignment.get_mapped_segments(segment) + start_segment_curve = segments[0] + end_segment_curve = start_segment_curve if segments[1] == None else segment[1] else: start_segment_curve = segment end_segment_curve = segment