Parameter wizard
Using the Parameter Wizard
Section titled “Using the Parameter Wizard”The Parameter Wizard gives you a visual way to add and manage interactive
parameters for your JSCAD scripts. Instead of writing getParameterDefinitions
by hand, you build the parameter list through a form and let the wizard generate
the code for you.
Opening the wizard
Section titled “Opening the wizard”Open any .jscad.js file in the editor. An Edit parameters… button appears
in the editor toolbar. Click it to open the wizard overlay.
If your file already contains a getParameterDefinitions function, the wizard
imports it automatically and shows your existing parameters ready to edit.
Adding a parameter
Section titled “Adding a parameter”Click + Add parameter to open the type picker. Parameters are grouped into four categories:
Number
| Type | Renders as |
|---|---|
slider |
A range slider with min, max, and step |
int |
A number input restricted to whole numbers |
float |
A number input that accepts decimals |
Selection
| Type | Renders as |
|---|---|
checkbox |
A toggle (produces true / false) |
choice |
A dropdown list |
radio |
A row of radio buttons |
color |
A colour picker (produces a hex string) |
Text
| Type | Renders as |
|---|---|
text |
A free-text input |
date |
A date picker |
email / url / password |
Specialised text inputs |
Layout
| Type | Renders as |
|---|---|
group |
A collapsible section heading to organise other parameters |
Editing a parameter
Section titled “Editing a parameter”Each parameter appears as a collapsible card. Expand it to edit its fields:
- Caption — the label shown to the user (e.g.
Wall thickness:) - Name — the JavaScript variable name used in
paramsinsidemain(). Auto-generated from the caption; edit it manually to override. - Initial / min / max / step — for numeric types, set the default value and the allowed range.
For choice and radio, the Options section lets you add and remove items.
Each option has a value (what the script receives) and a caption (what
the user sees).
Reordering parameters
Section titled “Reordering parameters”Drag a card by its handle to move it to a new position. You can also use the ↑ / ↓ arrow buttons on each card. Use group entries to create labelled sections that visually separate related parameters.
Live preview
Section titled “Live preview”The right panel shows exactly how the parameters will appear to a user running the script — sliders, dropdowns, colour pickers and all. It updates in real time as you make changes.
Applying the changes
Section titled “Applying the changes”Click Apply. The wizard writes the getParameterDefinitions function into
your file and re-runs the script immediately so you can see the parameters in
action in the renderer.
- If your file already has a
getParameterDefinitionsfunction it is replaced in place, leaving the rest of the file untouched. - If it does not, the function is inserted just before
main().
Click Cancel at any time to discard your changes and return to the editor.
Using parameters in your script
Section titled “Using parameters in your script”The wizard generates code like this:
const getParameterDefinitions = () => [ { name: 'width', type: 'number', widget: 'slider', caption: 'Width (mm):', default: 40, min: 10, max: 150, step: 1 }, { name: 'height', type: 'number', widget: 'slider', caption: 'Height (mm):', default: 20, min: 5, max: 100, step: 1 }, { name: 'color', type: 'color', caption: 'Color:', default: '#3498db' },]Access the values through the params argument of main():
function main({ width, height, color }) { const { cuboid } = require('@jscad/modeling').primitives const { colorize } = require('@jscad/modeling').colors
return colorize(color, cuboid({ size: [width, height, 10] }))}Every time the user moves a slider or picks a new colour, main() re-runs
automatically with the updated values.
Importing existing code
Section titled “Importing existing code”If you already have a getParameterDefinitions array written by hand, the
wizard can parse it. Click Import… inside the wizard, paste your code, and
click Import. The wizard will populate the parameter list from it.