mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +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]
|
return os.path.isfile(input_file) and "ifc" in os.path.splitext(input_file)[1]
|
||||||
|
|
||||||
def execute(self, context):
|
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(
|
ifcpatch.execute(
|
||||||
{
|
{
|
||||||
"input": context.scene.BIMPatchProperties.ifc_patch_input,
|
"input": context.scene.BIMPatchProperties.ifc_patch_input,
|
||||||
"output": context.scene.BIMPatchProperties.ifc_patch_output,
|
"output": context.scene.BIMPatchProperties.ifc_patch_output,
|
||||||
"recipe": context.scene.BIMPatchProperties.ifc_patch_recipes,
|
"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"),
|
"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 ...")
|
print("# Loading patch recipe ...")
|
||||||
recipes = getattr(__import__("ifcpatch.recipes.{}".format(args["recipe"])), "recipes")
|
recipes = getattr(__import__("ifcpatch.recipes.{}".format(args["recipe"])), "recipes")
|
||||||
recipe = getattr(recipes, args["recipe"])
|
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 ...")
|
print("# Patching ...")
|
||||||
patcher.patch()
|
patcher.patch()
|
||||||
ifc_file = getattr(patcher, "file_patched", patcher.file)
|
ifc_file = getattr(patcher, "file_patched", patcher.file)
|
||||||
|
|||||||
Reference in New Issue
Block a user