Alignment API updates to support new patch recipes

This commit is contained in:
Richard Brice
2025-07-20 15:32:26 -07:00
parent 3e0ef46a37
commit 3ef7f1c141
19 changed files with 481 additions and 160 deletions
@@ -20,6 +20,44 @@ import math
import ifcopenshell
import ifcopenshell.util.unit
def add_linear_placement_fallback_position(file:ifcopenshell.file)->ifcopenshell.file:
import ifcopenshell.api.alignment
patched_file = ifcopenshell.file.from_string(file.wrapped_data.to_string())
linear_placements = patched_file.by_type("IfcLinearPlacement")
for lp in linear_placements:
ifcopenshell.api.alignment.update_fallback_position(patched_file,lp)
return patched_file
def create_alignment_geometry(file:ifcopenshell.file)->ifcopenshell.file:
import ifcopenshell.api.alignment
patched_file = ifcopenshell.file.from_string(file.wrapped_data.to_string())
alignments = patched_file.by_type("IfcAlignment")
for alignment in alignments:
ifcopenshell.api.alignment.create_representation(patched_file,alignment)
return patched_file
def append_zero_length_segments(file:ifcopenshell.file)->ifcopenshell.file:
"""Appends zero length segments to all alignment layouts and layout geometry, if missing."""
import ifcopenshell.api.alignment
patched_file = ifcopenshell.file.from_string(file.wrapped_data.to_string())
alignments = patched_file.by_type("IfcAlignment")
for alignment in alignments:
layouts = ifcopenshell.api.alignment.get_alignment_layouts(alignment)
for layout in layouts:
ifcopenshell.api.alignment.add_zero_length_segment(patched_file,layout,include_referent=False)
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
if curve:
ifcopenshell.api.alignment.add_zero_length_segment(patched_file,curve)
return patched_file
def station_as_string(file: ifcopenshell.file, sta: float):
"""