Append IfcElements from linked IFC files

Example - https://imgur.com/a/phPcKSo

Appending ifc elements from library files will be deprecated as it's much more limited than appending it from linked files (in library you can only see object's name).
This commit is contained in:
Andrej730
2024-03-19 17:12:55 +05:00
parent c35cdcfcad
commit fcaac6bd98
3 changed files with 42 additions and 0 deletions
@@ -21,6 +21,7 @@ from . import ui, prop, operator, workspace, gizmo, decorator
classes = (
operator.AppendEntireLibrary,
operator.AppendInspectedLinkedElement,
operator.AppendLibraryElement,
operator.AppendLibraryElementByQuery,
operator.AssignLibraryDeclaration,
@@ -1514,6 +1514,7 @@ class LoadLinkedProject(bpy.types.Operator):
obj["guids"] = list(guids)
obj["guid_ids"] = list(guid_ids)
obj["db"] = self.db_filepath
obj["ifc_filepath"] = self.filepath
self.collection.objects.link(obj)
@@ -1645,6 +1646,42 @@ class QueryLinkedElement(bpy.types.Operator):
return self.execute(context)
class AppendInspectedLinkedElement(AppendLibraryElement):
bl_idname = "bim.append_inspected_linked_element"
bl_label = "Append Inspected Linked Element"
bl_description = "Append inspected linked element"
bl_options = {"REGISTER"}
def _execute(self, context):
from blenderbim.bim.module.project.data import LinksData
if not LinksData.linked_data:
self.report({"INFO"}, "No linked element found.")
return {"CANCELLED"}
guid = LinksData.linked_data["attributes"].get("GlobalId")
if guid is None:
self.report({"INFO"}, "Cannot find Global Id for element.")
return {"CANCELLED"}
queried_obj = context.scene.BIMProjectProperties.queried_obj
ifc_file = ifcopenshell.open(queried_obj["ifc_filepath"])
element_to_append = ifc_file.by_guid(guid)
element = ifcopenshell.api.run(
"project.append_asset",
tool.Ifc.get(),
library=ifc_file,
element=element_to_append,
)
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)
return {"FINISHED"}
class EnableCulling(bpy.types.Operator):
bl_idname = "bim.enable_culling"
bl_label = "Enable Culling"
@@ -326,6 +326,10 @@ class BIM_PT_links(Panel):
row.label(text="No Object Selected", icon="QUESTION")
return
row = self.layout.row(align=True)
row.label(text="")
row.operator("bim.append_inspected_linked_element", icon="APPEND_BLEND", text="")
for name, value in LinksData.linked_data["attributes"].items():
row = self.layout.row(align=True)
row.label(text=name)