From 9852e4fa5441f1d40e9410e849482de5ffa3a1f4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 11 Mar 2024 14:53:32 +0500 Subject: [PATCH] BBIM - option to append occurrences from the other ifc files Example - https://imgur.com/a/yASjbs8 --- .../blenderbim/bim/module/project/operator.py | 16 +++++++++++++++- .../blenderbim/bim/module/project/prop.py | 9 +++++++++ .../blenderbim/bim/module/project/ui.py | 6 ++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index 938ba91598..ce00103f1f 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -28,6 +28,7 @@ import ifcopenshell.api import ifcopenshell.util.selector import ifcopenshell.util.geolocation import ifcopenshell.util.representation +import ifcopenshell.util.element import blenderbim.bim.handler import blenderbim.bim.schema import blenderbim.tool as tool @@ -185,7 +186,11 @@ class RefreshLibrary(bpy.types.Operator): self.props.active_library_element = "" types = IfcStore.library_file.wrapped_data.types_with_super() - for importable_type in sorted(["IfcTypeProduct", "IfcMaterial", "IfcCostSchedule", "IfcProfileDef"]): + + element_classes = ["IfcTypeProduct", "IfcMaterial", "IfcCostSchedule", "IfcProfileDef"] + if self.props.library_display_elements: + element_classes += ["IfcElement"] + for importable_type in sorted(element_classes): if importable_type in types: new = self.props.library_elements.add() new.name = importable_type @@ -204,11 +209,15 @@ class ChangeLibraryElement(bpy.types.Operator): self.library_file = IfcStore.library_file ifc_classes = set() self.props.active_library_element = self.element_name + crumb = self.props.library_breadcrumb.add() crumb.name = self.element_name + elements = self.library_file.by_type(self.element_name) [ifc_classes.add(e.is_a()) for e in elements] + self.props.library_elements.clear() + if len(ifc_classes) == 1 and list(ifc_classes)[0] == self.element_name: for name, ifc_definition_id in sorted([(self.get_name(e), e.id()) for e in elements]): self.add_library_asset(name, ifc_definition_id) @@ -430,6 +439,11 @@ class AppendLibraryElement(bpy.types.Operator): self.import_type_from_ifc(element, context) elif element.is_a("IfcProduct"): self.import_product_from_ifc(element, context) + element_type = ifcopenshell.util.element.get_type(element) + obj = tool.Ifc.get_object(element_type) + if obj is None: + self.import_type_from_ifc(element_type, context) + elif element.is_a("IfcMaterial"): self.import_material_from_ifc(element, context) try: diff --git a/src/blenderbim/blenderbim/bim/module/project/prop.py b/src/blenderbim/blenderbim/bim/module/project/prop.py index e988a89f5b..1c38cc5c7c 100644 --- a/src/blenderbim/blenderbim/bim/module/project/prop.py +++ b/src/blenderbim/blenderbim/bim/module/project/prop.py @@ -59,6 +59,10 @@ def update_library_file(self, context): ) +def update_library_display_elements(self, context): + bpy.ops.bim.refresh_library() + + def update_filter_mode(self, context): self.filter_categories.clear() if self.filter_mode == "NONE": @@ -121,6 +125,11 @@ class BIMProjectProperties(PropertyGroup): organisation_name: StringProperty(name="Organisation") organisation_email: StringProperty(name="Organisation Email") authorisation: StringProperty(name="Authoriser") + library_display_elements: BoolProperty( + name="Display IfcElements", + description="Display IfcElements from library too, not just the types", + update=update_library_display_elements, + ) active_library_element: StringProperty(name="Enable Authoring Mode", default="") library_breadcrumb: CollectionProperty(name="Library Breadcrumb", type=StrProperty) library_elements: CollectionProperty(name="Library Elements", type=LibraryElement) diff --git a/src/blenderbim/blenderbim/bim/module/project/ui.py b/src/blenderbim/blenderbim/bim/module/project/ui.py index 1a73ef061b..351aee6941 100644 --- a/src/blenderbim/blenderbim/bim/module/project/ui.py +++ b/src/blenderbim/blenderbim/bim/module/project/ui.py @@ -267,12 +267,14 @@ class BIM_PT_project_library(Panel): ) row.operator("bim.append_library_element_by_query", text="", icon="APPEND_BLEND") row.operator("bim.save_library_file", text="", icon="EXPORT") + self.draw_library_ul() else: row.label(text="No Library Loaded", icon="ASSET_MANAGER") - if IfcStore.library_file: - self.draw_library_ul() def draw_library_ul(self): + self.layout.use_property_split = False + self.layout.prop(self.props, "library_display_elements") + self.layout.use_property_split = True if not self.props.library_elements: row = self.layout.row() row.label(text="No Assets Found", icon="ERROR")