diff --git a/src/blenderbim/Makefile b/src/blenderbim/Makefile index f90728a02e..973b705fc2 100644 --- a/src/blenderbim/Makefile +++ b/src/blenderbim/Makefile @@ -188,7 +188,7 @@ endif mkdir dist/working cd dist/working && wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js cd dist/working && wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css - cd dist/working && mv jsgantt* dist/blenderbim/bim/data/gantt/ + cp dist/working/jsgantt* dist/blenderbim/bim/data/gantt/ rm -rf dist/working # Required by IFCDiff diff --git a/src/blenderbim/blenderbim/bim/module/project/__init__.py b/src/blenderbim/blenderbim/bim/module/project/__init__.py index 576a026de3..d05306f3ce 100644 --- a/src/blenderbim/blenderbim/bim/module/project/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/project/__init__.py @@ -12,6 +12,7 @@ classes = ( operator.AssignLibraryDeclaration, operator.UnassignLibraryDeclaration, operator.SaveLibraryFile, + operator.AppendLibraryElement, prop.LibraryElement, prop.BIMProjectProperties, ui.BIM_PT_project, diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index 36eebc2549..a1c279c71c 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -4,6 +4,7 @@ import ifcopenshell import ifcopenshell.api import bpy from blenderbim.bim.ifc import IfcStore +from blenderbim.bim import import_ifc class CreateProject(bpy.types.Operator): @@ -220,3 +221,37 @@ class SaveLibraryFile(bpy.types.Operator): def execute(self, context): IfcStore.library_file.write(IfcStore.library_path) return {"FINISHED"} + + +class AppendLibraryElement(bpy.types.Operator): + bl_idname = "bim.append_library_element" + bl_label = "Append Library Element" + definition: bpy.props.IntProperty() + + def execute(self, context): + element = ifcopenshell.api.run( + "project.append_asset", + IfcStore.get_file(), + element=IfcStore.library_file.by_id(self.definition), + ) + self.import_type_from_ifc(element) + return {"FINISHED"} + + def import_type_from_ifc(self, element): + self.file = IfcStore.get_file() + logger = logging.getLogger("ImportIFC") + ifc_import_settings = import_ifc.IfcImportSettings.factory(bpy.context, IfcStore.path, logger) + + type_collection = bpy.data.collections.get("Types") + if not type_collection: + type_collection = bpy.data.collections.new("Types") + for collection in bpy.data.collections: + if "IfcProject/" in collection.name: + collection.children.link(type_collection) + break + + ifc_importer = import_ifc.IfcImporter(ifc_import_settings) + ifc_importer.file = self.file + ifc_importer.type_collection = type_collection + ifc_importer.create_type_product(element) + ifc_importer.place_objects_in_spatial_tree() diff --git a/src/blenderbim/blenderbim/bim/module/project/ui.py b/src/blenderbim/blenderbim/bim/module/project/ui.py index 4c62ad5c8d..82006ba3e1 100644 --- a/src/blenderbim/blenderbim/bim/module/project/ui.py +++ b/src/blenderbim/blenderbim/bim/module/project/ui.py @@ -71,6 +71,7 @@ class BIM_PT_project(Panel): class BIM_PT_project_library(Panel): bl_label = "IFC Project Library" bl_idname = "BIM_PT_project_library" + bl_options = {"DEFAULT_CLOSED"} bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" @@ -117,14 +118,16 @@ class BIM_UL_library(UIList): op.element_name = item.name row.label(text=item.name) if ( - not item.ifc_definition_id - or IfcStore.library_file.schema == "IFC2X3" - or not IfcStore.library_file.by_type("IfcProjectLibrary") + item.ifc_definition_id + and IfcStore.library_file.schema != "IFC2X3" + and IfcStore.library_file.by_type("IfcProjectLibrary") ): - return - if item.is_declared: - op = row.operator("bim.unassign_library_declaration", text="", icon="KEYFRAME_HLT", emboss=False) - op.definition = item.ifc_definition_id - else: - op = row.operator("bim.assign_library_declaration", text="", icon="KEYFRAME", emboss=False) + if item.is_declared: + op = row.operator("bim.unassign_library_declaration", text="", icon="KEYFRAME_HLT", emboss=False) + op.definition = item.ifc_definition_id + else: + op = row.operator("bim.assign_library_declaration", text="", icon="KEYFRAME", emboss=False) + op.definition = item.ifc_definition_id + if item.ifc_definition_id: + op = row.operator("bim.append_library_element", text="", icon="APPEND_BLEND") op.definition = item.ifc_definition_id diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py index 9d9b017f18..dc1aa1e29c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py @@ -23,6 +23,6 @@ class Usecase: ) elif self.settings["cost_item"]: ifcopenshell.api.run( - "nest.assign_object", self.file, object=cost_item, relating_object=self.settings["cost_item"] + "nest.assign_object", self.file, related_object=cost_item, relating_object=self.settings["cost_item"] ) return cost_item