From 8aa1b68d3ee0dc063115baee10cbd0a60e95960b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 4 Oct 2024 17:30:23 +0500 Subject: [PATCH] Bonsai - fix issues with default ifcpatch recipe is not loading properly #5540 --- src/bonsai/bonsai/bim/module/patch/operator.py | 3 +++ src/bonsai/bonsai/bim/module/patch/prop.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/patch/operator.py b/src/bonsai/bonsai/bim/module/patch/operator.py index 4de5add2c0..31bc036ddb 100644 --- a/src/bonsai/bonsai/bim/module/patch/operator.py +++ b/src/bonsai/bonsai/bim/module/patch/operator.py @@ -67,6 +67,9 @@ class ExecuteIfcPatch(bpy.types.Operator): @classmethod def poll(cls, context): props = context.scene.BIMPatchProperties + if props.ifc_patch_recipes == "-": + cls.poll_message_set("No recipe selected.") + return False 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 diff --git a/src/bonsai/bonsai/bim/module/patch/prop.py b/src/bonsai/bonsai/bim/module/patch/prop.py index 3c82c54726..52ac9fd4b8 100644 --- a/src/bonsai/bonsai/bim/module/patch/prop.py +++ b/src/bonsai/bonsai/bim/module/patch/prop.py @@ -47,6 +47,10 @@ def get_ifcpatch_recipes(self, context): global ifcpatchrecipes_enum if len(ifcpatchrecipes_enum) < 1: ifcpatchrecipes_enum.clear() + # Have to add a blank entry because otherwise default recipe might be not loaded + # properly (need to ensure bim.update_ifc_patch_arguments will be called). See #5540. + ifcpatchrecipes_enum.append(("-", "-", "")) + ifcpatch_path = Path(importlib.util.find_spec("ifcpatch").submodule_search_locations[0]) for filename in ifcpatch_path.joinpath("recipes").glob("*.py"): f = str(filename.stem)