bonsai, ifcopenshell - append IfcSurfaceStyles from other projects

And other IfcPresentationStyles, though they are not currently supported by bonsai.

Example - https://imgur.com/a/AHlvowp
This commit is contained in:
Andrej730
2024-08-15 13:57:00 +05:00
parent bd8a2736d4
commit 7597b1b29c
4 changed files with 65 additions and 7 deletions
@@ -25,7 +25,18 @@ import ifcopenshell.api.owner.settings
import ifcopenshell.util.element
import ifcopenshell.util.geolocation
import ifcopenshell.util.placement
from typing import Optional, Any, Union
from typing import Optional, Any, Union, Literal, get_args
APPENDABLE_ASSET = Literal[
"IfcTypeProduct",
"IfcProduct",
"IfcMaterial",
"IfcCostSchedule",
"IfcProfileDef",
"IfcPresentationStyle",
]
APPENDABLE_ASSET_TYPES = get_args(APPENDABLE_ASSET)
def append_asset(
@@ -154,6 +165,9 @@ class Usecase:
elif self.settings["element"].is_a("IfcProfileDef"):
self.target_class = "IfcProfileDef"
return self.append_profile_def()
elif self.settings["element"].is_a("IfcPresentationStyle"):
self.target_class = "IfcPresentationStyle"
return self.append_presentation_style()
def get_existing_element(self, element):
if element.id() in self.added_elements:
@@ -186,6 +200,10 @@ class Usecase:
self.whitelisted_inverse_attributes = {"IfcProfileDef": ["HasProperties"]}
return self.add_element(self.settings["element"])
def append_presentation_style(self):
self.whitelisted_inverse_attributes = {}
return self.add_element(self.settings["element"])
def append_type_product(self):
self.whitelisted_inverse_attributes = {
"IfcObjectDefinition": ["HasAssociations"],