Updated alignment stationing to account for stationing being defined on a parent alignment

This commit is contained in:
Richard Brice
2025-07-27 15:09:34 -07:00
parent e56f09071a
commit c8dbb72f69
2 changed files with 18 additions and 5 deletions
@@ -17,6 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
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