diff --git a/src/blenderbim/blenderbim/bim/module/patch/operator.py b/src/blenderbim/blenderbim/bim/module/patch/operator.py index 3752f12feb..b340b6ba37 100644 --- a/src/blenderbim/blenderbim/bim/module/patch/operator.py +++ b/src/blenderbim/blenderbim/bim/module/patch/operator.py @@ -48,14 +48,26 @@ class ExecuteIfcPatch(bpy.types.Operator): return os.path.isfile(input_file) and "ifc" in os.path.splitext(input_file)[1] def execute(self, context): - + if context.scene.BIMPatchProperties.ifc_patch_args_attr: + arguments = [] + for arg in context.scene.BIMPatchProperties.ifc_patch_args_attr: + if arg.data_type == "string": + arguments.append(arg.string_value) + if arg.data_type == "boolean": + arguments.append(arg.bool_value) + if arg.data_type == "integer": + arguments.append(arg.int_value) + if arg.data_type == "float": + arguments.append(arg.float_value) + else: + arguments = json.loads(context.scene.BIMPatchProperties.ifc_patch_args or "[]") ifcpatch.execute( { "input": context.scene.BIMPatchProperties.ifc_patch_input, "output": context.scene.BIMPatchProperties.ifc_patch_output, "recipe": context.scene.BIMPatchProperties.ifc_patch_recipes, - "arguments": json.loads(context.scene.BIMPatchProperties.ifc_patch_args or "[]"), + "arguments": arguments, "log": os.path.join(context.scene.BIMProperties.data_dir, "process.log"), } ) diff --git a/src/ifcpatch/ifcpatch/__init__.py b/src/ifcpatch/ifcpatch/__init__.py index 1675ecae94..3ca4f35f0d 100644 --- a/src/ifcpatch/ifcpatch/__init__.py +++ b/src/ifcpatch/ifcpatch/__init__.py @@ -13,7 +13,11 @@ def execute(args, is_library=None): print("# Loading patch recipe ...") recipes = getattr(__import__("ifcpatch.recipes.{}".format(args["recipe"])), "recipes") recipe = getattr(recipes, args["recipe"]) - patcher = recipe.Patcher(args["input"], ifc_file, logger, args["arguments"]) + try: + # We unpack the arguments if the Patcher has been type-hinted and docstringed + patcher = recipe.Patcher(args["input"], ifc_file, logger, *args["arguments"]) + except TypeError: + patcher = recipe.Patcher(args["input"], ifc_file, logger, args["arguments"]) print("# Patching ...") patcher.patch() ifc_file = getattr(patcher, "file_patched", patcher.file)