From d25f57ec40a9e4a172c474994fe9360277604683 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 1 Feb 2025 16:02:08 +1100 Subject: [PATCH] See #2981. Adding a door representation now also adds associated shape aspects It doesn't add materials though, that's a separate responsibility right now --- .../ifcopenshell/api/geometry/__init__.py | 2 ++ .../api/geometry/add_door_representation.py | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/__init__.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/__init__.py index 62f4765de6..8a253eee73 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/__init__.py @@ -44,6 +44,7 @@ try: from .add_representation import add_representation except ModuleNotFoundError as e: print(f"Note: API not available due to missing dependencies: geometry.add_representation - {e}") +from .add_shape_aspect import add_shape_aspect from .add_slab_representation import add_slab_representation from .add_wall_representation import add_wall_representation @@ -75,6 +76,7 @@ __all__ = [ "add_profile_representation", "add_railing_representation", "add_representation", + "add_shape_aspect", "add_slab_representation", "add_wall_representation", "add_window_representation", diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py index f11127171c..d622f0e07b 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py @@ -222,6 +222,7 @@ def add_door_representation( operation_type: DOOR_TYPE = "SINGLE_SWING_LEFT", lining_properties: Optional[Union[DoorLiningProperties, dict[str, Any]]] = None, panel_properties: Optional[Union[DoorPanelProperties, dict[str, Any]]] = None, + part_of_product: Optional[ifcopenshell.entity_instance] = None, unit_scale: Optional[float] = None, ) -> Union[ifcopenshell.entity_instance, None]: """Add a geometric representation for a door. @@ -272,6 +273,7 @@ def add_door_representation( "operation_type": operation_type, "lining_properties": lining_properties, "panel_properties": panel_properties, + "part_of_product": part_of_product, } ) usecase.settings = settings @@ -640,6 +642,29 @@ class Usecase: output_items = lining_offset_items + threshold_items + casing_items representation = builder.get_representation(self.settings["context"], output_items) + if self.settings["part_of_product"]: + ifcopenshell.api.geometry.add_shape_aspect( + self.file, + "Lining", + items=lining_items + window_lining_items + threshold_items + casing_items, + representation=representation, + part_of_product=self.settings["part_of_product"], + ) + ifcopenshell.api.geometry.add_shape_aspect( + self.file, + "Framing", + items=door_items + frame_items, + representation=representation, + part_of_product=self.settings["part_of_product"], + ) + if glass_items: + ifcopenshell.api.geometry.add_shape_aspect( + self.file, + "Glazing", + items=glass_items, + representation=representation, + part_of_product=self.settings["part_of_product"], + ) return representation @overload