mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user