mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
You can now append object types from an IFC project library to your active project
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -12,6 +12,7 @@ classes = (
|
||||
operator.AssignLibraryDeclaration,
|
||||
operator.UnassignLibraryDeclaration,
|
||||
operator.SaveLibraryFile,
|
||||
operator.AppendLibraryElement,
|
||||
prop.LibraryElement,
|
||||
prop.BIMProjectProperties,
|
||||
ui.BIM_PT_project,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user