From 0e1a2510ff9c2a7616b4598350386e8c1a785e4b Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 25 Feb 2026 10:24:30 +1100 Subject: [PATCH] Refactor get alignment layouts into util --- .../api/alignment/get_alignment_layouts.py | 14 +++----------- .../ifcopenshell/util/alignment.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_layouts.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_layouts.py index 5e05cf1fe4..c99001b07a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_layouts.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/get_alignment_layouts.py @@ -19,20 +19,12 @@ from collections.abc import Sequence from ifcopenshell import entity_instance +import ifcopenshell.util.alignment +# TODO remove this function, use util directly def get_alignment_layouts(alignment: entity_instance) -> Sequence[entity_instance]: """ Returns the layout alignments nested to this alignment """ - layouts = [] - for rel in alignment.IsNestedBy: - for layout in rel.RelatedObjects: - if ( - layout.is_a("IfcAlignmentHorizontal") - or layout.is_a("IfcAlignmentVertical") - or layout.is_a("IfcAlignmentCant") - ): - layouts.append(layout) - - return layouts + return ifcopenshell.util.alignment.get_alignment_layouts(alignment) diff --git a/src/ifcopenshell-python/ifcopenshell/util/alignment.py b/src/ifcopenshell-python/ifcopenshell/util/alignment.py index 1b90ac7c5f..c6a332fa7f 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/alignment.py +++ b/src/ifcopenshell-python/ifcopenshell/util/alignment.py @@ -20,6 +20,7 @@ import math import ifcopenshell import ifcopenshell.util.unit +from typing import Sequence def add_linear_placement_fallback_position(file: ifcopenshell.file) -> ifcopenshell.file: @@ -109,3 +110,19 @@ def station_as_string(file: ifcopenshell.file, sta: float): station_string = "-" + station_string return station_string + + +def get_alignment_layouts(alignment: ifcopenshell.entity_instance) -> Sequence[ifcopenshell.entity_instance]: + """ + Returns the layout alignments nested to this alignment + """ + layouts = [] + for rel in alignment.IsNestedBy: + for layout in rel.RelatedObjects: + if ( + layout.is_a("IfcAlignmentHorizontal") + or layout.is_a("IfcAlignmentVertical") + or layout.is_a("IfcAlignmentCant") + ): + layouts.append(layout) + return layouts