mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
fix: Correct vertical/cant segment handling in alignment API
Two bugs prevented IfcAlignmentVertical segments from being added when
a geometric representation exists.
Bug 1 — _add_segment_to_curve.py:
Removed an unconditional `if not curve.is_a("IfcCompositeCurve")` guard
that was left over from when the function only supported horizontal
segments. The preceding if/elif/elif chain already validates the correct
curve type for each segment type; the redundant check always raised
TypeError for vertical (IfcGradientCurve) and cant
(IfcSegmentedReferenceCurve) segments.
Bug 2 — add_zero_length_segment.py:
Added a None guard before the recursive `add_zero_length_segment(file,
layout.BaseCurve)` call for IfcGradientCurve. When an IfcGradientCurve
is created without a BaseCurve (e.g. before a horizontal representation
exists), the recursive call previously crashed with AttributeError.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -128,10 +128,6 @@ def _add_segment_to_curve(file: ifcopenshell.file, segment: entity_instance, cur
|
|||||||
elif segment.DesignParameters.is_a("IfcAlignmentCantSegment") and not curve.is_a("IfcSegmentedReferenceCurve"):
|
elif segment.DesignParameters.is_a("IfcAlignmentCantSegment") and not curve.is_a("IfcSegmentedReferenceCurve"):
|
||||||
raise TypeError(f"Expected to see IfcSegmentedReferenceCurve, instead received '{curve.is_a()}'.")
|
raise TypeError(f"Expected to see IfcSegmentedReferenceCurve, instead received '{curve.is_a()}'.")
|
||||||
|
|
||||||
expected_type = "IfcCompositeCurve"
|
|
||||||
if not curve.is_a(expected_type):
|
|
||||||
raise TypeError(f"Expected to see {expected_type}, instead received {curve.is_a()}.")
|
|
||||||
|
|
||||||
# map the IfcAlignmentSegment to an IfcCurveSegment (or two in the case of helmert curves)
|
# map the IfcAlignmentSegment to an IfcCurveSegment (or two in the case of helmert curves)
|
||||||
if segment.DesignParameters.is_a("IfcAlignmentHorizontalSegment"):
|
if segment.DesignParameters.is_a("IfcAlignmentHorizontalSegment"):
|
||||||
mapped_segments = _map_alignment_horizontal_segment(file, segment)
|
mapped_segments = _map_alignment_horizontal_segment(file, segment)
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ def add_zero_length_segment(file: ifcopenshell.file, layout: entity_instance, in
|
|||||||
if layout.is_a("IfcSegmentedReferenceCurve"):
|
if layout.is_a("IfcSegmentedReferenceCurve"):
|
||||||
ifcopenshell.api.alignment.add_zero_length_segment(file, layout.BaseCurve)
|
ifcopenshell.api.alignment.add_zero_length_segment(file, layout.BaseCurve)
|
||||||
elif layout.is_a("IfcGradientCurve"):
|
elif layout.is_a("IfcGradientCurve"):
|
||||||
ifcopenshell.api.alignment.add_zero_length_segment(file, layout.BaseCurve)
|
if layout.BaseCurve is not None:
|
||||||
|
ifcopenshell.api.alignment.add_zero_length_segment(file, layout.BaseCurve)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
zero_length_curve_segment = None
|
zero_length_curve_segment = None
|
||||||
|
|||||||
Reference in New Issue
Block a user