Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 2ac0b75

Browse files
committed
New Link IFC operator to easily append IFCs from another Blend file into a master file
1 parent fb79989 commit 2ac0b75

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/ifcblenderexport/blenderbim/bim/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
operator.SetBlenderClashSetB,
232232
operator.ExecuteBlenderClash,
233233
operator.CleanWireframes,
234+
operator.LinkIfc,
234235
prop.StrProperty,
235236
prop.Attribute,
236237
prop.MaterialLayer,

src/ifcblenderexport/blenderbim/bim/operator.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4862,3 +4862,30 @@ def execute(self, context):
48624862
if not obj.modifiers.get("EdgeSplit"):
48634863
obj.modifiers.new("EdgeSplit", "EDGE_SPLIT")
48644864
return {"FINISHED"}
4865+
4866+
4867+
class LinkIfc(bpy.types.Operator):
4868+
bl_idname = "bim.link_ifc"
4869+
bl_label = "Link IFC"
4870+
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
4871+
4872+
def execute(self, context):
4873+
#bpy.context.active_object.active_material.BIMMaterialProperties.location = self.filepath
4874+
#coll_name = "MyCollection"
4875+
4876+
with bpy.data.libraries.load(self.filepath, link=True) as (data_from, data_to):
4877+
data_to.scenes = data_from.scenes
4878+
4879+
for scene in bpy.data.scenes:
4880+
if not scene.library or scene.library.filepath != self.filepath:
4881+
continue
4882+
for child in scene.collection.children:
4883+
if "IfcProject" not in child.name:
4884+
continue
4885+
bpy.data.scenes[0].collection.children.link(child)
4886+
4887+
return {"FINISHED"}
4888+
4889+
def invoke(self, context, event):
4890+
context.window_manager.fileselect_add(self)
4891+
return {"RUNNING_MODAL"}

src/ifcblenderexport/blenderbim/bim/ui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,6 +2305,8 @@ def draw(self, context):
23052305

23062306
row = layout.row(align=True)
23072307
row.operator("bim.clean_wireframes")
2308+
row = layout.row(align=True)
2309+
row.operator("bim.link_ifc")
23082310

23092311
row = layout.row(align=True)
23102312
op = row.operator("bim.add_annotation", text="Dim", icon="ARROW_LEFTRIGHT")

0 commit comments

Comments
 (0)