mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 21:12:07 +00:00
Fixes position of zero-length segment
This commit is contained in:
@@ -91,14 +91,6 @@ def _add_segment_to_layout(file: ifcopenshell.file, layout: entity_instance, seg
|
|||||||
|
|
||||||
segment_nest = ifcopenshell.api.alignment.get_alignment_segment_nest(layout)
|
segment_nest = ifcopenshell.api.alignment.get_alignment_segment_nest(layout)
|
||||||
zero_length_segment = segment_nest.RelatedObjects[-1]
|
zero_length_segment = segment_nest.RelatedObjects[-1]
|
||||||
# DesignParameters.StartPoint for IfcAlignmentHorizontalSegment is automatically updated when the
|
|
||||||
# geometric representation is updated because the semantic and geometric data use the same IfcPoint.
|
|
||||||
# This is not the case of IfcAlignmentVerticalSegment and IfcAlignmentCantSegment. For these
|
|
||||||
# segment types, the design parameters of the zero length segment must be updated explicitly.
|
|
||||||
if zero_length_segment.DesignParameters.is_a(
|
|
||||||
"IfcAlignmentVerticalSegment"
|
|
||||||
) or zero_length_segment.DesignParameters.is_a("IfcAlignmentCantSegment"):
|
|
||||||
# get the geometric representation for the new segment
|
|
||||||
mapped_segments = ifcopenshell.api.alignment.get_mapped_segments(segment)
|
mapped_segments = ifcopenshell.api.alignment.get_mapped_segments(segment)
|
||||||
mapped_segment = mapped_segments[0] if mapped_segments[1] == None else mapped_segments[1]
|
mapped_segment = mapped_segments[0] if mapped_segments[1] == None else mapped_segments[1]
|
||||||
|
|
||||||
@@ -110,7 +102,14 @@ def _add_segment_to_layout(file: ifcopenshell.file, layout: entity_instance, seg
|
|||||||
end = np.array(e)
|
end = np.array(e)
|
||||||
|
|
||||||
# update the zero length segment semantic representation parameters
|
# update the zero length segment semantic representation parameters
|
||||||
if zero_length_segment.DesignParameters.is_a("IfcAlignmentVerticalSegment"):
|
if zero_length_segment.DesignParameters.is_a("IfcAlignmentHorizontalSegment"):
|
||||||
|
x = float(end[0, 3]) / unit_scale
|
||||||
|
y = float(end[1, 3]) / unit_scale
|
||||||
|
dx = float(end[0, 0])
|
||||||
|
dy = float(end[1, 0])
|
||||||
|
zero_length_segment.DesignParameters.StartPoint.Coordinates = (x,y)
|
||||||
|
zero_length_segment.DesignParameters.StartDirection = dy / dx
|
||||||
|
elif zero_length_segment.DesignParameters.is_a("IfcAlignmentVerticalSegment"):
|
||||||
y = float(end[1, 3]) / unit_scale
|
y = float(end[1, 3]) / unit_scale
|
||||||
zero_length_segment.DesignParameters.StartHeight = y
|
zero_length_segment.DesignParameters.StartHeight = y
|
||||||
dx = float(end[0, 0])
|
dx = float(end[0, 0])
|
||||||
|
|||||||
Reference in New Issue
Block a user