mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
You can now load multiple Blends simultaneously when linking IFCs
This commit is contained in:
@@ -107,9 +107,9 @@ class SelectLibraryFile(bpy.types.Operator, IFCFileSelector):
|
|||||||
def commit(self, data):
|
def commit(self, data):
|
||||||
IfcStore.library_path = data["filepath"]
|
IfcStore.library_path = data["filepath"]
|
||||||
IfcStore.library_file = ifcopenshell.open(data["filepath"])
|
IfcStore.library_file = ifcopenshell.open(data["filepath"])
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
self.layout.prop(self, "append_all", text= "Append Entire Library")
|
self.layout.prop(self, "append_all", text="Append Entire Library")
|
||||||
|
|
||||||
|
|
||||||
class RefreshLibrary(bpy.types.Operator):
|
class RefreshLibrary(bpy.types.Operator):
|
||||||
@@ -291,7 +291,7 @@ class SaveLibraryFile(bpy.types.Operator):
|
|||||||
class AppendEntiryLibrary(bpy.types.Operator):
|
class AppendEntiryLibrary(bpy.types.Operator):
|
||||||
bl_idname = "bim.append_entire_library"
|
bl_idname = "bim.append_entire_library"
|
||||||
bl_label = "Append Entiry Library"
|
bl_label = "Append Entiry Library"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return IfcStore.get_file()
|
return IfcStore.get_file()
|
||||||
@@ -302,13 +302,15 @@ class AppendEntiryLibrary(bpy.types.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
self.library = IfcStore.library_file
|
self.library = IfcStore.library_file
|
||||||
|
|
||||||
lib_elements = ifcopenshell.util.selector.Selector().parse(self.library, '.IfcTypeProduct | .IfcMaterial | .IfcCostSchedule| .IfcProfileDef')
|
lib_elements = ifcopenshell.util.selector.Selector().parse(
|
||||||
|
self.library, ".IfcTypeProduct | .IfcMaterial | .IfcCostSchedule| .IfcProfileDef"
|
||||||
|
)
|
||||||
for element in lib_elements:
|
for element in lib_elements:
|
||||||
bpy.ops.bim.append_library_element(definition= element.id())
|
bpy.ops.bim.append_library_element(definition=element.id())
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class AppendLibraryElement(bpy.types.Operator):
|
class AppendLibraryElement(bpy.types.Operator):
|
||||||
bl_idname = "bim.append_library_element"
|
bl_idname = "bim.append_library_element"
|
||||||
bl_label = "Append Library Element"
|
bl_label = "Append Library Element"
|
||||||
@@ -660,16 +662,19 @@ class LinkIfc(bpy.types.Operator):
|
|||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Link a Blender file"
|
bl_description = "Link a Blender file"
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
files: bpy.props.CollectionProperty(name="Files", type=bpy.types.OperatorFileListElement)
|
||||||
|
directory: bpy.props.StringProperty(subtype="DIR_PATH")
|
||||||
filter_glob: bpy.props.StringProperty(default="*.blend;*.blend1", options={"HIDDEN"})
|
filter_glob: bpy.props.StringProperty(default="*.blend;*.blend1", options={"HIDDEN"})
|
||||||
use_relative_path: bpy.props.BoolProperty(name="Use Relative Path", default=False)
|
use_relative_path: bpy.props.BoolProperty(name="Use Relative Path", default=False)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
new = context.scene.BIMProjectProperties.links.add()
|
for file in self.files:
|
||||||
filepath = self.filepath
|
filepath = os.path.join(self.directory, file.name)
|
||||||
if self.use_relative_path:
|
new = context.scene.BIMProjectProperties.links.add()
|
||||||
filepath = os.path.relpath(filepath, bpy.path.abspath("//"))
|
if self.use_relative_path:
|
||||||
new.name = filepath
|
filepath = os.path.relpath(filepath, bpy.path.abspath("//"))
|
||||||
bpy.ops.bim.load_link(filepath=self.filepath)
|
new.name = filepath
|
||||||
|
bpy.ops.bim.load_link(filepath=self.filepath)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
|
|||||||
Reference in New Issue
Block a user