OpenSCAD User Manual/Customizer

Customizer
The Customizer feature provides a graphic user interface for editing model parameters. With this feature one does not need to edit the code to change the values of the parameters / variables. Programmers can create templates for a given model, and customize these further to adapt to different needs / users. Sets of parameter values can also be saved, which effectively saves a variant of a particular model.

Activation of Customizer panel
If the Customizer panel is not displayed, use the menu toggle Window > Hide customizer to make it visible.

Supported Variables
The customizer displays all variables that meet the following criteria:

Because it appears after a {, the Customizer does not display the variable debug_mode. This is an old-fashioned way of ending the list of customizable parameters -- the comment /* [Hidden] */ is considered a best-practice way to do this now.
 * The variable is assigned in the main file. Customizer will not display variables from files brought in via include and use (though with include, they can still be referenced in the calling script).
 * The variable has a simple literal value -- string, number, or boolean -- or a list of up to four numeric literals.
 * The variable is not assigned in a "Hidden" section, as defined by a line containing only the comment /* [Hidden] */ (details below).
 * The assignment statement must appear before the first { syntax element. Some scripts contain an empty module near the top for just this purpose, for instance:

Note: It is possible to enter a module or function containing no { character, which would not stop the Customizer from displaying subsequent variables.

As mentioned above, only simple literals and arrays of up to four numbers are available as parameters. Examples for literals are: a = "Text"; b = 123; c = 456.789; d = [1,2,3,4];

Expressions (even trivial examples) like e = str("String"," ","concat"); f = 12 + 0.5; are not supported as parameters.

Syntax support for generation of the customization form
The description comment must be adjusted to the left column of the source file, without spaces.

Following is the syntax for how to define different types of widgets in the form:

Slider
Only numbers are allowed in this one, specify any of the following:

Note that this is mainly for compatibility with Thingiverse

Checkbox
Not supported by Thingiverse.

Textbox
NOTE: The text box example only works in release version 2021.01, it may not work in future versions!

Special vector
You can also set a range for the vector:

Unavailable customizations
Some desirable customization constraints are not supported currently.
 * Multi-line text boxes.
 * Directly editable (non-spinbox) numeric values:

Creating Tabs
Parameters can be grouped into tabs. This feature allows related parameters to be associated into groups. The syntax is very similar the Thingiverse rules for tabs. To create a tab, use a multi-line block comment like this:

/* [Tab Name] */

Also possible, but not recommended: /* [Tab] [Name] */

Three tabs names have a special functionality;

[Global]
Parameters in the Global tab are always shown on every tab no matter which tab is selected. No tab is shown for Global parameters; they appear in all the tabs.

[Hidden]
Parameters in the Hidden tab (with first letter uppercase) are never displayed. Not even the tab is shown. This prevents global variables that have not been parameterized for the Thingiverse or OpenSCAD Customizer from showing up in the Customizer interface or widget. Included for compatibility with Thingiverse.

You can have multiples segments under the Hidden group. See also

parameters
Parameters that are not under any tab are displayed under a tab named “parameters”. In Thingiverse, these parameters are listed with no tab.

Saving Parameters value in JSON file
This feature gives the user the ability to save the values of all parameters. JSON parameter values can be then reused through the command line.

Cmdline
And JSON file is written in the following format:
 * -p is used to give input JSON file in which parameters are saved.
 * -P is used to give the name of the set of the parameters written in JSON file.

GUI
Through GUI you can easily apply and save Parameter in JSON file using Present section in Customizer explained below.

In customizer, the first line of options is as follows:
 * 1) Automatic Preview: If checked, the preview of the model is automatically updated when you change any parameter in Customizer, else you must click the preview button or press F5 after you update parameters in the Customizer.
 * 2) Show Details:
 * 3) Show Details: If chosen, the description for the parameter appears below the parameter name.
 * 4) Inline Details: If chosen, the description for the parameter appears next to the parameter name. Long descriptions get clipped. This option is a compromise between vertical space usage and retaining part of the description.
 * 5) Hide Details: Details are suppressed although you still can view the description by hovering the cursor over the input widget.
 * 6) Reset button: When clicked, it resets the values of all input widgets for the parameter to the defaults provided in SCAD file.

Next comes Preset section: It consist of four buttons:
 * combo Box
 * It is used to select the set of parameters to be used


 * + button
 * add new set of the parameters


 * – button
 * It is used to delete the set selected in combo Box.


 * save preset button
 * save/overwrite the current preset

and finally below Preset Section is the Place where you can play with the parameters.

You can also refer to two examples that are Part of OpenSCAD to learn more:
 * 1) Parametric/sign.scad
 * 2) Parametric/candlStand.scad

manually create datasets
You can manually create a dataset by modifying the JSON file according above format and defining your own variables. When a dataset is loaded, only the parameters defined in the dataset are modified, other parameters are not set to defaults. This allow one to create partial datasets consisting of modifiers, not complete dataset.

hidden parameters
Variables belonging to the hidden group are stored in the JSON file, but are not retrieved from the JSON file.

Meaning: If a variable is moved from the hidden group to an other group, it also becomes applicable. This allows a designer to use the hidden group for reserved variables, that become customizable (and assigned with a different default) in a future version, without breaking existing preset.

A hidden variable can also be used as a "last saved with" indicator, that can be read by manually viewing the JSON file.

The idea is, that the customizer only modifies variables that the user can see and control from the customizer UI.

Set Range and Stepping
The customizer tries to guess an appropriate range and stepping, but may give inconsistent results depending on your design intent. For example, the customizer also treats numbers like 0.0, 1.0, 2.0 etc. as integers. The customizer also does not know whether negative numbers make sense. It is therefore recommended to supply range and step as comments. Keep in mind, that if in doubt, the user can always modify the SCAD file.

Do not hesitate to limit the range. For instance, in the design of a smart phone holder, limit the size to reasonable smart phone sizes. If someone wants to use your smart phone holder as a tablet holder, he always can directly edit the SCAD file itself. This act also makes the user aware, that the design was not meant as a tablet holder and that he or she might need for example to modify the support structure

Scroll Wheel
The buttons on the spinboxes are small, but you can use the scroll wheel on your mouse to change the value comfortably. First, click on the spin box to focus the spin box.

color
cubeColor = [1,0.5,0]; //[0:0.1:1] sphereColor = "blue"; // [red, green, blue]

echo(cubeColor);

color(cubeColor) cube;

color(sphereColor) sphere;