mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Correctly unpack arguments when Patching IFC
This commit is contained in:
@@ -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"),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user