diff --git a/src/bonsai/bonsai/bim/module/csv/operator.py b/src/bonsai/bonsai/bim/module/csv/operator.py index 480dae7458..4fc31ae91f 100644 --- a/src/bonsai/bonsai/bim/module/csv/operator.py +++ b/src/bonsai/bonsai/bim/module/csv/operator.py @@ -183,6 +183,14 @@ class ExportIfcCsv(bpy.types.Operator): filename_ext = ".csv" filepath: bpy.props.StringProperty(subtype="FILE_PATH") + @classmethod + def poll(cls, context): + props = context.scene.CsvProperties + if not props.should_load_from_memory and not props.csv_ifc_file: + cls.poll_message_set("Select an IFC file or use 'load from memory' if it's loaded in Bonsai.") + return False + return True + def invoke(self, context, event): props = context.scene.CsvProperties if props.format == "web": @@ -268,6 +276,14 @@ class ImportIfcCsv(bpy.types.Operator): filter_glob: bpy.props.StringProperty(default="*.csv;*.ods;*.xlsx", options={"HIDDEN"}) filepath: bpy.props.StringProperty(subtype="FILE_PATH") + @classmethod + def poll(cls, context): + props = context.scene.CsvProperties + if not props.should_load_from_memory and not props.csv_ifc_file: + cls.poll_message_set("Select an IFC file or use 'load from memory' if it's loaded in Bonsai.") + return False + return True + def invoke(self, context, event): self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".csv") WindowManager = context.window_manager diff --git a/src/bonsai/bonsai/bim/module/fm/operator.py b/src/bonsai/bonsai/bim/module/fm/operator.py index cd9a8559f0..a7c4906325 100644 --- a/src/bonsai/bonsai/bim/module/fm/operator.py +++ b/src/bonsai/bonsai/bim/module/fm/operator.py @@ -36,7 +36,10 @@ class ExecuteIfcFM(bpy.types.Operator): @classmethod def poll(cls, context): props = context.scene.BIMFMProperties - return props.should_load_from_memory or props.ifc_files.single_file + if not props.should_load_from_memory and not props.ifc_files.single_file: + cls.poll_message_set("Select an IFC file or use 'load from memory' if it's loaded in Bonsai.") + return False + return True def invoke(self, context, event): props = context.scene.BIMFMProperties diff --git a/src/bonsai/bonsai/bim/module/light/operator.py b/src/bonsai/bonsai/bim/module/light/operator.py index ff6dbf71b5..7ad7a5da55 100644 --- a/src/bonsai/bonsai/bim/module/light/operator.py +++ b/src/bonsai/bonsai/bim/module/light/operator.py @@ -54,8 +54,15 @@ class ExportOBJ(bpy.types.Operator): bl_label = "Export" bl_description = "Export the IFC to OBJ" - def execute(self, context): + @classmethod + def poll(cls, context): + props = context.scene.radiance_exporter_properties + if not props.should_load_from_memory and not props.ifc_file: + cls.poll_message_set("Select an IFC file or use 'load from memory' if it's loaded in Bonsai.") + return False + return True + def execute(self, context): # Get the output directory should_load_from_memory = context.scene.radiance_exporter_properties.should_load_from_memory output_dir = context.scene.radiance_exporter_properties.output_dir diff --git a/src/bonsai/bonsai/bim/module/patch/operator.py b/src/bonsai/bonsai/bim/module/patch/operator.py index 60876c4d4d..cdec1a8b73 100644 --- a/src/bonsai/bonsai/bim/module/patch/operator.py +++ b/src/bonsai/bonsai/bim/module/patch/operator.py @@ -70,8 +70,11 @@ class ExecuteIfcPatch(bpy.types.Operator): @classmethod def poll(cls, context): - input_file = context.scene.BIMPatchProperties.ifc_patch_input - return input_file or context.scene.BIMPatchProperties.should_load_from_memory + props = context.scene.BIMPatchProperties + if not props.should_load_from_memory and not props.ifc_patch_input: + cls.poll_message_set("Select an IFC file or use 'load from memory' if it's loaded in Bonsai.") + return False + return True def execute(self, context): props = context.scene.BIMPatchProperties diff --git a/src/bonsai/bonsai/bim/module/tester/operator.py b/src/bonsai/bonsai/bim/module/tester/operator.py index 50c710accb..cd466bc377 100644 --- a/src/bonsai/bonsai/bim/module/tester/operator.py +++ b/src/bonsai/bonsai/bim/module/tester/operator.py @@ -37,7 +37,12 @@ class ExecuteIfcTester(bpy.types.Operator, tool.Ifc.Operator): @classmethod def poll(cls, context): props = context.scene.IfcTesterProperties - return (props.ifc_files.single_file or props.should_load_from_memory) and props.specs + if not props.should_load_from_memory and not props.ifc_files.single_file: + cls.poll_message_set("Select an IFC file or use 'load from memory' if it's loaded in Bonsai.") + return False + if not props.specs: + return False + return True def execute(self, context): props = context.scene.IfcTesterProperties