mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
alignment api cleanup
updates some documentation removes some dead code
This commit is contained in:
@@ -38,8 +38,7 @@ def _is_zero_length_segment(segment: entity_instance) -> bool:
|
|||||||
def clear_layout_segments(file: ifcopenshell.file, layout: entity_instance) -> None:
|
def clear_layout_segments(file: ifcopenshell.file, layout: entity_instance) -> None:
|
||||||
"""
|
"""
|
||||||
Clear all segments from a layout while preserving the layout entity
|
Clear all segments from a layout while preserving the layout entity
|
||||||
and zero-length terminator. After calling this, use
|
and zero-length terminator.
|
||||||
layout_horizontal_alignment_by_pi_method() to add new segments.
|
|
||||||
|
|
||||||
This function removes:
|
This function removes:
|
||||||
- All real (non-zero-length) IfcAlignmentSegment entities from the layout
|
- All real (non-zero-length) IfcAlignmentSegment entities from the layout
|
||||||
|
|||||||
@@ -30,91 +30,6 @@ from ifcopenshell.api.alignment._create_polyline_representation import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _create_layout(file: ifcopenshell.file, alignment: entity_instance, points: Sequence[entity_instance]):
|
|
||||||
"""
|
|
||||||
I don't believe it is required for polylines, but the validation serivce gives an error if the alignment doesn't have a layout
|
|
||||||
"""
|
|
||||||
include_vertical = False if points[0].Dim == 2 else True
|
|
||||||
|
|
||||||
alignment_layouts = []
|
|
||||||
|
|
||||||
alignment_layouts.append(file.createIfcAlignmentHorizontal(GlobalId=ifcopenshell.guid.new()))
|
|
||||||
|
|
||||||
if include_vertical:
|
|
||||||
alignment_layouts.append(file.createIfcAlignmentVertical(GlobalId=ifcopenshell.guid.new()))
|
|
||||||
|
|
||||||
ifcopenshell.api.nest.assign_object(file, related_objects=alignment_layouts, relating_object=alignment)
|
|
||||||
|
|
||||||
start_dist_along = 0.0
|
|
||||||
for p1, p2 in zip(points, points[1:]):
|
|
||||||
x1, y1, z1 = p1.Coordinates
|
|
||||||
x2, y2, z2 = p2.Coordinates
|
|
||||||
dir = math.atan2(y2 - y1, x2 - x1)
|
|
||||||
gradient = (z2 - z1) / (x2 - x1)
|
|
||||||
length = math.sqrt(math.pow((x2 - x1), 2.0) + math.pow((y2 - y1), 2.0))
|
|
||||||
|
|
||||||
hsegment = file.createIfcAlignmentSegment(
|
|
||||||
ifcopenshell.guid.new(),
|
|
||||||
DesignParameters=file.createIfcAlignmentHorizontalSegment(
|
|
||||||
StartPoint=p1,
|
|
||||||
StartDirection=dir,
|
|
||||||
StartRadiusOfCurvature=0.0,
|
|
||||||
EndRadiusOfCurvature=0.0,
|
|
||||||
SegmentLength=length,
|
|
||||||
PredefinedType="LINE",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
ifcopenshell.api.nest.assign_object(file, related_objects=[hsegment], relating_object=alignment_layouts[0])
|
|
||||||
|
|
||||||
if include_vertical:
|
|
||||||
vsegment = file.createIfcAlignmentSegment(
|
|
||||||
ifcopenshell.guid.new(),
|
|
||||||
DesignParameters=file.createIfcAlignmentVerticalSegment(
|
|
||||||
StartDistAlong=start_dist_along,
|
|
||||||
HorizontalLength=length,
|
|
||||||
StartHeight=z1,
|
|
||||||
StartGradient=gradient,
|
|
||||||
EndGradient=gradient,
|
|
||||||
PredefinedType="CONSTANTGRADIENT",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
ifcopenshell.api.nest.assign_object(file, related_objects=[vsegment], relating_object=alignment_layouts[1])
|
|
||||||
|
|
||||||
start_dist_along += length
|
|
||||||
|
|
||||||
# zero length segment
|
|
||||||
hsegment = file.createIfcAlignmentSegment(
|
|
||||||
ifcopenshell.guid.new(),
|
|
||||||
DesignParameters=file.createIfcAlignmentHorizontalSegment(
|
|
||||||
StartPoint=points[-1],
|
|
||||||
StartDirection=dir,
|
|
||||||
StartRadiusOfCurvature=0.0,
|
|
||||||
EndRadiusOfCurvature=0.0,
|
|
||||||
SegmentLength=0.0,
|
|
||||||
PredefinedType="LINE",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
ifcopenshell.api.nest.assign_object(file, related_objects=[hsegment], relating_object=alignment_layouts[0])
|
|
||||||
|
|
||||||
if include_vertical:
|
|
||||||
vsegment = file.createIfcAlignmentSegment(
|
|
||||||
ifcopenshell.guid.new(),
|
|
||||||
DesignParameters=file.createIfcAlignmentVerticalSegment(
|
|
||||||
StartDistAlong=start_dist_along,
|
|
||||||
HorizontalLength=0.0,
|
|
||||||
StartHeight=points[-1].Coordinates[-1],
|
|
||||||
StartGradient=gradient,
|
|
||||||
EndGradient=gradient,
|
|
||||||
PredefinedType="CONSTANTGRADIENT",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
ifcopenshell.api.nest.assign_object(file, related_objects=[vsegment], relating_object=alignment_layouts[1])
|
|
||||||
|
|
||||||
|
|
||||||
def create_as_polyline(
|
def create_as_polyline(
|
||||||
file: ifcopenshell.file,
|
file: ifcopenshell.file,
|
||||||
name: str,
|
name: str,
|
||||||
|
|||||||
Reference in New Issue
Block a user