From c8dbb72f69bfe15b61ab6993820b516d09021cef Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Sun, 27 Jul 2025 15:09:34 -0700 Subject: [PATCH] Updated alignment stationing to account for stationing being defined on a parent alignment --- .../api/alignment/_add_segment_to_layout.py | 6 ++++++ .../api/alignment/get_alignment_station.py | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py index 3b137a4d74..0eb4ecde02 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_add_segment_to_layout.py @@ -163,6 +163,12 @@ def _add_segment_to_layout(file: ifcopenshell.file, layout: entity_instance, seg end_referent.ObjectPlacement.CartesianPosition.Axis.DirectionRatios = (ax, ay, az) end_referent.ObjectPlacement.CartesianPosition.RefDirection.DirectionRatios = (rx, ry, rz) + start_station = ifcopenshell.api.alignment.get_alignment_station(file,alignment) + end_referent_station = start_station + start_dist_along + pset_stationing = ifcopenshell.api.pset.add_pset(file, product=end_referent, name="Pset_Stationing") + ifcopenshell.api.pset.edit_pset(file, pset=pset_stationing, properties={"Station": end_referent_station}) + + # create the start of segment referent # get the previous segment. Working from the end of the basis curve, -1 is zero length segment diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_station.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_station.py index aa129e7889..4f9b853113 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_station.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_station.py @@ -17,6 +17,7 @@ # along with IfcOpenShell. If not, see . import ifcopenshell +import ifcopenshell.api.alignment import ifcopenshell.util.element from ifcopenshell import entity_instance @@ -32,10 +33,16 @@ def get_alignment_station(file: ifcopenshell.file, alignment: entity_instance) - raise TypeError(f"Expected entity type to be IfcAlignment, instead received {alignment.is_a()}") start_station = 0.0 - components = ifcopenshell.util.element.get_components(alignment) - for c in components: - if c.is_a("IfcReferent") and ifcopenshell.util.element.get_predefined_type(c) == "STATION": - start_station = ifcopenshell.util.element.get_pset(c, name="Pset_Stationing", prop="Station") - break + + parent_alignment = ifcopenshell.api.alignment.get_parent_alignment(alignment) + if parent_alignment: + start_station = ifcopenshell.api.alignment.get_alignment_station(file,parent_alignment) + else: + components = ifcopenshell.util.element.get_components(alignment) + for c in components: + if c.is_a("IfcReferent") and ifcopenshell.util.element.get_predefined_type(c) == "STATION": + start_station = ifcopenshell.util.element.get_pset(c, name="Pset_Stationing", prop="Station") + break + return start_station