Skip to content

Commit

Permalink
Feature/params fix cadquery contrib (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
openvmp authored Oct 14, 2024
1 parent d10241e commit acb702b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ Define parts with CodeCAD scripts using the following syntax:
<part name>:
type: <openscad|cadquery|build123d>
cwd: <alternative current working directory>
showObject: <(optional) the name of the object to show using "show_object(...)">
patch:
# ...regexp substitutions to apply...
"patern": "repl"
Expand Down
10 changes: 5 additions & 5 deletions partcad/src/partcad/part_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ def normalize(name, config):
"type": "string",
"default": param_value,
}
elif isinstance(param_value, float):
elif isinstance(param_value, bool):
config["parameters"][param_name] = {
"type": "int",
"type": "bool",
"default": param_value,
}
elif isinstance(param_value, int):
elif isinstance(param_value, float):
config["parameters"][param_name] = {
"type": "float",
"default": param_value,
}
elif isinstance(param_value, bool):
elif isinstance(param_value, int):
config["parameters"][param_name] = {
"type": "bool",
"type": "int",
"default": param_value,
}
elif isinstance(param_value, list):
Expand Down
2 changes: 1 addition & 1 deletion partcad/src/partcad/part_factory_build123d.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def instantiate(self, part):
if "show" in self.config:
patch["\\Z"] = "\nshow(%s)\n" % self.config["show"]
if "showObject" in self.config:
patch["\\Z"] = "\nshow_object(%s)\n" % self.config["show"]
patch["\\Z"] = "\nshow_object(%s)\n" % self.config["showObject"]
if "patch" in self.config:
patch.update(self.config["patch"])
request["patch"] = patch
Expand Down
4 changes: 4 additions & 0 deletions partcad/src/partcad/part_factory_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ async def instantiate(self, part):
for param_name, param in self.config["parameters"].items():
request["build_parameters"][param_name] = param["default"]
patch = {}
if "show" in self.config:
patch["\\Z"] = "\nshow(%s)\n" % self.config["show"]
if "showObject" in self.config:
patch["\\Z"] = "\nshow_object(%s)\n" % self.config["showObject"]
if "patch" in self.config:
patch.update(self.config["patch"])
request["patch"] = patch
Expand Down
10 changes: 5 additions & 5 deletions partcad/src/partcad/provider_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def normalize(name, config):
"type": "string",
"default": param_value,
}
elif isinstance(param_value, float):
elif isinstance(param_value, bool):
config["parameters"][param_name] = {
"type": "int",
"type": "bool",
"default": param_value,
}
elif isinstance(param_value, int):
elif isinstance(param_value, float):
config["parameters"][param_name] = {
"type": "float",
"default": param_value,
}
elif isinstance(param_value, bool):
elif isinstance(param_value, int):
config["parameters"][param_name] = {
"type": "bool",
"type": "int",
"default": param_value,
}
elif isinstance(param_value, list):
Expand Down
10 changes: 5 additions & 5 deletions partcad/src/partcad/sketch_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ def normalize(name, config):
"type": "string",
"default": param_value,
}
elif isinstance(param_value, float):
elif isinstance(param_value, bool):
config["parameters"][param_name] = {
"type": "int",
"type": "bool",
"default": param_value,
}
elif isinstance(param_value, int):
elif isinstance(param_value, float):
config["parameters"][param_name] = {
"type": "float",
"default": param_value,
}
elif isinstance(param_value, bool):
elif isinstance(param_value, int):
config["parameters"][param_name] = {
"type": "bool",
"type": "int",
"default": param_value,
}
elif isinstance(param_value, list):
Expand Down

0 comments on commit acb702b

Please sign in to comment.