From 2912eafcfa1b55e09aec42627f345133956096f2 Mon Sep 17 00:00:00 2001 From: Roman Kuzmenko Date: Thu, 10 Oct 2024 23:50:42 -0700 Subject: [PATCH] Added support for array parameters --- partcad/src/partcad/part_config.py | 5 +++++ partcad/src/partcad/project.py | 8 ++++++++ partcad/src/partcad/provider_config.py | 5 +++++ partcad/src/partcad/sketch_config.py | 5 +++++ 4 files changed, 23 insertions(+) diff --git a/partcad/src/partcad/part_config.py b/partcad/src/partcad/part_config.py index 2740aab7..9f91913b 100644 --- a/partcad/src/partcad/part_config.py +++ b/partcad/src/partcad/part_config.py @@ -43,6 +43,11 @@ def normalize(name, config): "type": "bool", "default": param_value, } + elif isinstance(param_value, list): + config["parameters"][param_name] = { + "type": "array", + "default": param_value, + } # All params are float unless another type is explicitly speciifed elif ( isinstance(param_value, dict) and not "type" in param_value diff --git a/partcad/src/partcad/project.py b/partcad/src/partcad/project.py index 24e1cc69..9ac2240c 100644 --- a/partcad/src/partcad/project.py +++ b/partcad/src/partcad/project.py @@ -559,6 +559,8 @@ def get_sketch(self, sketch_name, func_params=None) -> sketch.Sketch: config["parameters"][param_name]["default"] = bool( param_value ) + elif config["parameters"][param_name]["type"] == "array": + config["parameters"][param_name]["default"] = param_value else: # Filling "with" if not "with" in config: @@ -796,6 +798,8 @@ def get_part(self, part_name, func_params=None, quiet=False) -> part.Part: config["parameters"][param_name]["default"] = bool( param_value ) + elif config["parameters"][param_name]["type"] == "array": + config["parameters"][param_name]["default"] = param_value else: # Filling "with" if not "with" in config: @@ -989,6 +993,8 @@ def get_assembly( config["parameters"][param_name]["default"] = bool( param_value ) + elif config["parameters"][param_name]["type"] == "array": + config["parameters"][param_name]["default"] = param_value else: # Filling "with" if not "with" in config: @@ -1196,6 +1202,8 @@ def get_provider( config["parameters"][param_name]["default"] = bool( param_value ) + elif config["parameters"][param_name]["type"] == "array": + config["parameters"][param_name]["default"] = param_value else: # Filling "with" if not "with" in config: diff --git a/partcad/src/partcad/provider_config.py b/partcad/src/partcad/provider_config.py index b10fcf7f..282b9a1a 100644 --- a/partcad/src/partcad/provider_config.py +++ b/partcad/src/partcad/provider_config.py @@ -46,6 +46,11 @@ def normalize(name, config): "type": "bool", "default": param_value, } + elif isinstance(param_value, list): + config["parameters"][param_name] = { + "type": "array", + "default": param_value, + } # All params are float unless another type is explicitly speciifed elif ( isinstance(param_value, dict) and not "type" in param_value diff --git a/partcad/src/partcad/sketch_config.py b/partcad/src/partcad/sketch_config.py index 1372b0fb..d5cefd78 100644 --- a/partcad/src/partcad/sketch_config.py +++ b/partcad/src/partcad/sketch_config.py @@ -43,6 +43,11 @@ def normalize(name, config): "type": "bool", "default": param_value, } + elif isinstance(param_value, list): + config["parameters"][param_name] = { + "type": "array", + "default": param_value, + } # All params are float unless another type is explicitly speciifed elif ( isinstance(param_value, dict) and not "type" in param_value