mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
feat: Allow selecting multiple IFC and IDS files in the IFC tester
This implements the "MultipleFileSelector" for the file selection in the "IFC Tester" panel, so multiple files can be selected at once. Attention: This commit only adds the User Interface, the actual functionality will be added in a later commit
This commit is contained in:
committed by
Dion Moult
parent
bbd4e00972
commit
94bcb8d266
@@ -27,6 +27,7 @@ import ifctester.reporter
|
||||
import ifcopenshell
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.bim.handler
|
||||
from blenderbim.bim.operator import MultipleFileSelector
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -92,38 +93,32 @@ class ExecuteIfcTester(bpy.types.Operator, tool.Ifc.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectSpecs(bpy.types.Operator):
|
||||
class SelectSpecs(MultipleFileSelector):
|
||||
bl_idname = "bim.select_specs"
|
||||
bl_label = "Select IDS"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
filename_ext = ".ids"
|
||||
filter_glob: bpy.props.StringProperty(default="*.ids;*.xml", options={"HIDDEN"})
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.IfcTesterProperties.specs = self.filepath
|
||||
props = context.scene.IfcTesterProperties
|
||||
|
||||
self.update_props(props, "specs", props.specs_files)
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
|
||||
class SelectIfcTesterIfcFile(bpy.types.Operator):
|
||||
class SelectIfcTesterIfcFile(MultipleFileSelector):
|
||||
bl_idname = "bim.select_ifctester_ifc_file"
|
||||
bl_label = "Select IfcTester IFC File"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
filename_ext = ".ifc"
|
||||
filter_glob: bpy.props.StringProperty(default="*.ifc;*.ifczip;*.ifcxml", options={"HIDDEN"})
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.IfcTesterProperties.ifc_file = self.filepath
|
||||
return {"FINISHED"}
|
||||
props = context.scene.IfcTesterProperties
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {"RUNNING_MODAL"}
|
||||
self.update_props(props, "ifc_file", props.ifc_files)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectRequirement(bpy.types.Operator):
|
||||
|
||||
@@ -49,7 +49,9 @@ class FailedEntities(PropertyGroup):
|
||||
|
||||
class IfcTesterProperties(PropertyGroup):
|
||||
specs: StringProperty(default="", name="IDS File")
|
||||
specs_files: CollectionProperty(name="IDS Files", type=StrProperty)
|
||||
ifc_file: StringProperty(default="", name="IFC File")
|
||||
ifc_files: CollectionProperty(name="IFC Files", type=StrProperty)
|
||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
|
||||
generate_html_report: BoolProperty(default=False, name="Generate HTML report", options=set())
|
||||
generate_ods_report: BoolProperty(default=False, name="Generate ODS report", options=set())
|
||||
|
||||
@@ -50,11 +50,18 @@ class BIM_PT_tester(Panel):
|
||||
|
||||
if not tool.Ifc.get() or not props.should_load_from_memory:
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(props, "ifc_file")
|
||||
if len(props.ifc_files) > 1:
|
||||
row.label(text=f"{len(props.ifc_files)} Files Selected")
|
||||
else:
|
||||
row.prop(props, "ifc_file")
|
||||
|
||||
row.operator("bim.select_ifctester_ifc_file", icon="FILE_FOLDER", text="")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(props, "specs")
|
||||
if len(props.specs_files) > 1:
|
||||
row.label(text=f"{len(props.specs_files)} Files Selected")
|
||||
else:
|
||||
row.prop(props, "specs")
|
||||
row.operator("bim.select_specs", icon="FILE_FOLDER", text="")
|
||||
|
||||
row = self.layout.row()
|
||||
|
||||
Reference in New Issue
Block a user