mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Alignment API updates to support new patch recipes
This commit is contained in:
@@ -26,25 +26,29 @@ def has_zero_length_segment(layout: entity_instance) -> bool:
|
||||
"""
|
||||
Returns true if the layout ends with a zero length segment.
|
||||
|
||||
:param layout: An IfcAlignmentHorizontal, IfcAlignmentVertical, or IfcAlignmentCant
|
||||
:param layout: An IfcAlignmentHorizontal, IfcAlignmentVertical, IfcAlignmentCant, IfcCompositeCurve, IfcGradientCurve, or IfcSegmentedReferenceCurve
|
||||
:return: True if the zero length segment is present
|
||||
"""
|
||||
expected_types = ["IfcAlignmentHorizontal", "IfcAlignmentVertical", "IfcAlignmentCant"]
|
||||
expected_types = ["IfcAlignmentHorizontal", "IfcAlignmentVertical", "IfcAlignmentCant","IfcCompositeCurve","IfcGradientCurve","IfcSegmentedReferenceCurve"]
|
||||
if not layout.is_a() in expected_types:
|
||||
raise TypeError(
|
||||
f"Expected entity type to be one of {[_ for _ in expected_types]}, instead received '{layout.is_a()}"
|
||||
)
|
||||
|
||||
result = False
|
||||
for rel in layout.IsNestedBy:
|
||||
if 0 < len(rel.RelatedObjects):
|
||||
last_segment = rel.RelatedObjects[-1]
|
||||
if last_segment.is_a("IfcAlignmentSegment"):
|
||||
if last_segment.DesignParameters.is_a("IfcAlignmentHorizontalSegment"):
|
||||
result = last_segment.DesignParameters.SegmentLength == 0.0
|
||||
elif last_segment.DesignParameters.is_a("IfcAlignmentVerticalSegment"):
|
||||
result = last_segment.DesignParameters.HorizontalLength == 0.0
|
||||
elif last_segment.DesignParameters.is_a("IfcAlignmentCantSegment"):
|
||||
result = last_segment.DesignParameters.HorizontalLength == 0.0
|
||||
|
||||
if layout.is_a("IfcCompositeCurve") or layout.is_a("IfcGradientCurve") or layout.is_a("IfcSegmentedReferenceCurve"):
|
||||
result = True if layout.Segments and 0 < len(layout.Segments) and layout.Segments[-1].SegmentLength.wrappedValue == 0.0 else False
|
||||
else:
|
||||
for rel in layout.IsNestedBy:
|
||||
if 0 < len(rel.RelatedObjects):
|
||||
last_segment = rel.RelatedObjects[-1]
|
||||
if last_segment.is_a("IfcAlignmentSegment"):
|
||||
if last_segment.DesignParameters.is_a("IfcAlignmentHorizontalSegment"):
|
||||
result = last_segment.DesignParameters.SegmentLength == 0.0
|
||||
elif last_segment.DesignParameters.is_a("IfcAlignmentVerticalSegment"):
|
||||
result = last_segment.DesignParameters.HorizontalLength == 0.0
|
||||
elif last_segment.DesignParameters.is_a("IfcAlignmentCantSegment"):
|
||||
result = last_segment.DesignParameters.HorizontalLength == 0.0
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user