Use regular json if no docstring when Patching

This commit is contained in:
Gorgious
2021-08-05 15:03:49 +02:00
parent 497cf76c8e
commit efa1e245c5
2 changed files with 3 additions and 12 deletions
@@ -41,6 +41,7 @@ class ExecuteIfcPatch(bpy.types.Operator):
bl_idname = "bim.execute_ifc_patch"
bl_label = "Execute IFCPatch"
file_format: bpy.props.StringProperty()
use_json_for_args: bpy.props.BoolProperty()
@classmethod
def poll(cls, context):
@@ -48,18 +49,7 @@ 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:
if self.use_json_for_args or not context.scene.BIMPatchProperties.ifc_patch_args_attr:
arguments = json.loads(context.scene.BIMPatchProperties.ifc_patch_args or "[]")
else:
arguments = [arg.get_value() for arg in context.scene.BIMPatchProperties.ifc_patch_args_attr]
@@ -51,3 +51,4 @@ class BIM_PT_patch(bpy.types.Panel):
row = layout.row()
op = row.operator("bim.execute_ifc_patch")
op.use_json_for_args = not bool(docs["inputs"])