mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
BBIM - option to append occurrences from the other ifc files
Example - https://imgur.com/a/yASjbs8
This commit is contained in:
@@ -28,6 +28,7 @@ import ifcopenshell.api
|
|||||||
import ifcopenshell.util.selector
|
import ifcopenshell.util.selector
|
||||||
import ifcopenshell.util.geolocation
|
import ifcopenshell.util.geolocation
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
|
import ifcopenshell.util.element
|
||||||
import blenderbim.bim.handler
|
import blenderbim.bim.handler
|
||||||
import blenderbim.bim.schema
|
import blenderbim.bim.schema
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
@@ -185,7 +186,11 @@ class RefreshLibrary(bpy.types.Operator):
|
|||||||
self.props.active_library_element = ""
|
self.props.active_library_element = ""
|
||||||
|
|
||||||
types = IfcStore.library_file.wrapped_data.types_with_super()
|
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:
|
if importable_type in types:
|
||||||
new = self.props.library_elements.add()
|
new = self.props.library_elements.add()
|
||||||
new.name = importable_type
|
new.name = importable_type
|
||||||
@@ -204,11 +209,15 @@ class ChangeLibraryElement(bpy.types.Operator):
|
|||||||
self.library_file = IfcStore.library_file
|
self.library_file = IfcStore.library_file
|
||||||
ifc_classes = set()
|
ifc_classes = set()
|
||||||
self.props.active_library_element = self.element_name
|
self.props.active_library_element = self.element_name
|
||||||
|
|
||||||
crumb = self.props.library_breadcrumb.add()
|
crumb = self.props.library_breadcrumb.add()
|
||||||
crumb.name = self.element_name
|
crumb.name = self.element_name
|
||||||
|
|
||||||
elements = self.library_file.by_type(self.element_name)
|
elements = self.library_file.by_type(self.element_name)
|
||||||
[ifc_classes.add(e.is_a()) for e in elements]
|
[ifc_classes.add(e.is_a()) for e in elements]
|
||||||
|
|
||||||
self.props.library_elements.clear()
|
self.props.library_elements.clear()
|
||||||
|
|
||||||
if len(ifc_classes) == 1 and list(ifc_classes)[0] == self.element_name:
|
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]):
|
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)
|
self.add_library_asset(name, ifc_definition_id)
|
||||||
@@ -430,6 +439,11 @@ class AppendLibraryElement(bpy.types.Operator):
|
|||||||
self.import_type_from_ifc(element, context)
|
self.import_type_from_ifc(element, context)
|
||||||
elif element.is_a("IfcProduct"):
|
elif element.is_a("IfcProduct"):
|
||||||
self.import_product_from_ifc(element, context)
|
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"):
|
elif element.is_a("IfcMaterial"):
|
||||||
self.import_material_from_ifc(element, context)
|
self.import_material_from_ifc(element, context)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -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):
|
def update_filter_mode(self, context):
|
||||||
self.filter_categories.clear()
|
self.filter_categories.clear()
|
||||||
if self.filter_mode == "NONE":
|
if self.filter_mode == "NONE":
|
||||||
@@ -121,6 +125,11 @@ class BIMProjectProperties(PropertyGroup):
|
|||||||
organisation_name: StringProperty(name="Organisation")
|
organisation_name: StringProperty(name="Organisation")
|
||||||
organisation_email: StringProperty(name="Organisation Email")
|
organisation_email: StringProperty(name="Organisation Email")
|
||||||
authorisation: StringProperty(name="Authoriser")
|
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="")
|
active_library_element: StringProperty(name="Enable Authoring Mode", default="")
|
||||||
library_breadcrumb: CollectionProperty(name="Library Breadcrumb", type=StrProperty)
|
library_breadcrumb: CollectionProperty(name="Library Breadcrumb", type=StrProperty)
|
||||||
library_elements: CollectionProperty(name="Library Elements", type=LibraryElement)
|
library_elements: CollectionProperty(name="Library Elements", type=LibraryElement)
|
||||||
|
|||||||
@@ -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.append_library_element_by_query", text="", icon="APPEND_BLEND")
|
||||||
row.operator("bim.save_library_file", text="", icon="EXPORT")
|
row.operator("bim.save_library_file", text="", icon="EXPORT")
|
||||||
|
self.draw_library_ul()
|
||||||
else:
|
else:
|
||||||
row.label(text="No Library Loaded", icon="ASSET_MANAGER")
|
row.label(text="No Library Loaded", icon="ASSET_MANAGER")
|
||||||
if IfcStore.library_file:
|
|
||||||
self.draw_library_ul()
|
|
||||||
|
|
||||||
def draw_library_ul(self):
|
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:
|
if not self.props.library_elements:
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.label(text="No Assets Found", icon="ERROR")
|
row.label(text="No Assets Found", icon="ERROR")
|
||||||
|
|||||||
Reference in New Issue
Block a user