From 2b4d4439ea495f02d5c0325616fa45d7b5bed905 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 17 Sep 2021 14:00:25 +1000 Subject: [PATCH] Fix bug where IFC patch didn't work on case insensitive file extensions --- .../blenderbim/bim/module/patch/operator.py | 2 +- .../blenderbim/bim/module/patch/prop.py | 4 +-- .../test/bim/module/patch/__init__.py | 0 .../test/bim/module/patch/test_operator.py | 32 +++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/blenderbim/test/bim/module/patch/__init__.py create mode 100644 src/blenderbim/test/bim/module/patch/test_operator.py diff --git a/src/blenderbim/blenderbim/bim/module/patch/operator.py b/src/blenderbim/blenderbim/bim/module/patch/operator.py index 1babe6948b..e8c4d1b89c 100644 --- a/src/blenderbim/blenderbim/bim/module/patch/operator.py +++ b/src/blenderbim/blenderbim/bim/module/patch/operator.py @@ -67,7 +67,7 @@ class ExecuteIfcPatch(bpy.types.Operator): @classmethod def poll(cls, context): input_file = context.scene.BIMPatchProperties.ifc_patch_input - return os.path.isfile(input_file) and "ifc" in os.path.splitext(input_file)[1] + return os.path.isfile(input_file) and "ifc" in os.path.splitext(input_file)[1].lower() def execute(self, context): props = context.scene.BIMPatchProperties diff --git a/src/blenderbim/blenderbim/bim/module/patch/prop.py b/src/blenderbim/blenderbim/bim/module/patch/prop.py index ecf130c9b1..27c0e44ab5 100644 --- a/src/blenderbim/blenderbim/bim/module/patch/prop.py +++ b/src/blenderbim/blenderbim/bim/module/patch/prop.py @@ -42,7 +42,7 @@ def purge(): ifcpatchrecipes_enum = [] -def getIfcPatchRecipes(self, context): +def get_ifcpatch_recipes(self, context): global ifcpatchrecipes_enum if len(ifcpatchrecipes_enum) < 1: ifcpatchrecipes_enum.clear() @@ -61,7 +61,7 @@ def update_ifc_patch_recipe(self, context): class BIMPatchProperties(PropertyGroup): - ifc_patch_recipes: EnumProperty(items=getIfcPatchRecipes, name="Recipes", update=update_ifc_patch_recipe) + ifc_patch_recipes: EnumProperty(items=get_ifcpatch_recipes, name="Recipes", update=update_ifc_patch_recipe) ifc_patch_input: StringProperty(default="", name="IFC Patch Input IFC") ifc_patch_output: StringProperty(default="", name="IFC Patch Output IFC") ifc_patch_args: StringProperty(default="", name="Arguments") diff --git a/src/blenderbim/test/bim/module/patch/__init__.py b/src/blenderbim/test/bim/module/patch/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/blenderbim/test/bim/module/patch/test_operator.py b/src/blenderbim/test/bim/module/patch/test_operator.py new file mode 100644 index 0000000000..2603b1ee7a --- /dev/null +++ b/src/blenderbim/test/bim/module/patch/test_operator.py @@ -0,0 +1,32 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2021 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + +import test.bim.bootstrap + + +class TestExecuteIfcPatch(test.bim.bootstrap.NewFile): + @test.bim.bootstrap.scenario + def test_executing_ifcpatch(self): + return """ + Given I set "scene.BIMPatchProperties.ifc_patch_recipes" to "OffsetObjectPlacements" + And I set "scene.BIMPatchProperties.ifc_patch_input" to "{cwd}/test/files/basic.ifc" + And I set "scene.BIMPatchProperties.ifc_patch_output" to "{cwd}/test/files/basic-patched.ifc" + And I set "scene.BIMPatchProperties.ifc_patch_args" to "[123454321,0,0,0]" + When I press "bim.execute_ifc_patch" + Then the file "{cwd}/test/files/basic-patched.ifc" should contain "123454321" + """