Skip to content

Commit 1586c85

Browse files
committed
added option to import all library assets
1 parent bab6313 commit 1586c85

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/blenderbim/blenderbim/bim/module/project/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
operator.RefreshLibrary,
3737
operator.RewindLibrary,
3838
operator.SaveLibraryFile,
39+
operator.AppendEntiryLibrary,
3940
operator.SelectLibraryFile,
4041
operator.ToggleFilterCategories,
4142
operator.ToggleLinkVisibility,

src/blenderbim/blenderbim/bim/module/project/operator.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class SelectLibraryFile(bpy.types.Operator, IFCFileSelector):
7171
bl_description = "Select an IFC file that can be used as a library"
7272
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
7373
filter_glob: bpy.props.StringProperty(default="*.ifc;*.ifczip;*.ifcxml", options={"HIDDEN"})
74+
append_all: bpy.props.BoolProperty(default=False)
7475

7576
def execute(self, context):
7677
IfcStore.begin_transaction(self)
@@ -87,6 +88,8 @@ def _execute(self, context):
8788
bpy.ops.bim.refresh_library()
8889
if context.area:
8990
context.area.tag_redraw()
91+
if self.append_all:
92+
bpy.ops.bim.append_entire_library()
9093
return {"FINISHED"}
9194

9295
def invoke(self, context, event):
@@ -104,6 +107,9 @@ def rollback(self, data):
104107
def commit(self, data):
105108
IfcStore.library_path = data["filepath"]
106109
IfcStore.library_file = ifcopenshell.open(data["filepath"])
110+
111+
def draw(self, context):
112+
self.layout.prop(self, "append_all", text= "Append Entire Library")
107113

108114

109115
class RefreshLibrary(bpy.types.Operator):
@@ -282,6 +288,27 @@ def execute(self, context):
282288
return {"FINISHED"}
283289

284290

291+
class AppendEntiryLibrary(bpy.types.Operator):
292+
bl_idname = "bim.append_entire_library"
293+
bl_label = "Append Entiry Library"
294+
295+
@classmethod
296+
def poll(cls, context):
297+
return IfcStore.get_file()
298+
299+
def execute(self, context):
300+
return IfcStore.execute_ifc_operator(self, context)
301+
302+
def _execute(self, context):
303+
self.file = IfcStore.get_file()
304+
self.library = IfcStore.library_file
305+
306+
lib_elements = ifcopenshell.util.selector.Selector().parse(self.library, '.IfcTypeProduct | .IfcMaterial | .IfcCostSchedule| .IfcProfileDef')
307+
for element in lib_elements:
308+
bpy.ops.bim.append_library_element(definition= element.id())
309+
return {"FINISHED"}
310+
311+
285312
class AppendLibraryElement(bpy.types.Operator):
286313
bl_idname = "bim.append_library_element"
287314
bl_label = "Append Library Element"

0 commit comments

Comments
 (0)