User Interface for Customizing Models ( Part 2)

In the last blog, we left at How to parameterize the variables. Now next thing is to group the parameters so that it become easy to manage those parameters.Parameters can be grouped into tabs. This feature will allow us to separate similar and related parameters.

The syntax for this is also mainly similar to that of Thingiverse syntax for creating the tabs. To create a tab, use a multi-line block comment like this:

/* [Tab Name] */

The following tab names are reserved for special functionality:

  • [Global]
    Parameters in the global tab will always be shown on every tab no matter which tab is selected. Note: there will be no tab for “Global” params, they will just always be shown in all the tabs.
  • [Hidden]
    Parameters in the hidden tab will never be displayed. Not even the tab will be shown. Even though the varaibles who have not been parameterized using the thingiverse or natvie syntax will not be displayed in openscad parameter widget but we have implemented this to make our comment like syntax similar as that of thinigverse.

Also the parmeters who are under no tab will be diplayed under TAB named “parameters”.

    
/* [Drop down box:] */
// combo box for nunber
Numbers=2; // [0, 1, 2, 3]

// combo box for string
Strings="foo"; // [foo, bar, baz]

//labeled combo box for numbers
Labeled_values=10; // [10:L, 20:M, 30:XL]

//labeled combo box for string
Labeled_value="S"; // [S:Small, M:Medium, L:Large]

/*[ Slider ]*/
// slider widget for number
slider =34; // [10:100]

//step slider for number
stepSlider=2; //[0:5:100]

/* [Checkbox] */

//description
Variable = true; //comment

/*[Spinbox] */

// spinbox with step size 23
Spinbox = 5; //23

/* [Textbox] */

//Text box for vector with more than 4 elements
Vector=[12,34,44,43,23,23];//comment

// Text box for string
String="hello"; //comment

/* [Special vector] */
//Text box for vector with less than or equal to 4 elements
Vector2=[12,34,45,23]; //any thing

This will create the following Tabs:

Screenshot from 2016-07-04 17:37:07

We can also use the native syntax for grouping this:
Note: This is planed for future but not included in yet in final PR

@Group("Tab Name")
@parameter()
variable=value;

Similarly, we can use @group(“Hidden”) and @group(“Global”).

@Group("Global")
@Description("sdad")
@Parameter([0, 1, 2, 3, 8])
Numbers = "3";

@Group("Global")
@Description("combo box for string")
@Parameter(["foo", "bar", "baz"])
Strings = "bar";

@Group("Hidden")
@Description("labeled combo box for numbers")
@Parameter([[10, "L"], [20, "M"], [30, "XL"]])
Labeled_values = 10;

@Group("Hidden")
@Description("labeled combo box for string")
@Parameter([["S", "Small"], ["M", "Medium"], ["L", "Large"]])
Labeled_value = " /*S */ ";

@Group("Hidden")
@Description("slider widget for number")
@Parameter([10 : 100])
slider = 12;

@Group("Hidden")
@Description("step slider for number")
@Parameter([0 : 5 : 100])
stepSlider = 2;

@Group("checkbox")
@Description("Checkbox for boolean ")
@Parameter("any comment")
Variable = true;

@Group(" spinBox")
@Description("spinbox with step size 23")
@Parameter(23)
Spinbox = 5;

@Group("Text box")
@Description("Text box for string")
@Parameter("comment")
String = "hello";

@Group("Text box")
@Description("Text box for vector with more than 4 elements ")
@Parameter([12, 34, 343, 43, 43, 42, 313])
Vector = [12, 34, 45, 12, 23, 56];

@Group("special vector")
@Description("Text box for vector with less than or equal to 4 elements ")
@Parameter("any thing")
Vector2 = [12, 34, 45, 23];
cube(Numbers);

Screenshot from 2016-07-18 15:05:08.png

Save the set of parameters in JSON file

This feature which is unique to openSCAD give user the ability to save the value of the parameter and also we can apply them through the cmd-line and get the output.

Cmdline:

    openscad -o model-2.stl -p parameters.json -P model-2 model.scad

Here,

openscad -o <output-file> -p <parameteric-file> -P <NameOfSet> input-file
  • -p is used to give input JSON file in which parameters are saved
  • -P is used to give the name of set of the parameters written in JSON file

And JSON file is written in the following format:

{
    "SET":
    {
        "FirstSet":
        {
            "Labeled_value": " \/*S *\/ ",
            "Labled_values": "13",
            "Numbers": "18",
            "Spinbox": "35",
            "Vector": "[2, 34, 45, 12, 23, 56]",
            "slider": "2",
            "stepSlider": "12",
            "string": "he"
        },
        "SeconSet":
        {
            "Labeled_value": " \/*S *\/ ",
            "Labled_values": "10",
            "Numbers": "8",
            "Spinbox": "5",
            "Vector": "[12, 34, 45, 12, 23, 56]",
            "slider": "12",
            "stepSlider": "2",
            "string": "hello"
        }
    }
}
{
    "SET":{
               < set-name >:{
                          < parameter-name > : < value >,
                          < parameter-name > : < value >
                        },
              < set-name >:{
                          < parameter-name > : < value >,
                          < parameter-name > : < value >
                        },
    }
}

GUI:

There are three widgets in Parameter Widget

combo Box
It is used to select the set of parameters to be used
+ button
  1. It is used to update the set selected in combo Box. On clicking + button values of parameters in set are replaced by new values
  2. If we select “No set selected” in comboBox, then we can use + button to add new set of the parameters
– button
It is used to delete the set selected in combo Box.

Screenshot from 2016-07-17 00:06:34

Make sure to check it out at and provide a feedback:

Latest snapshots( with Thingiverse syntax):

 

 

Old Snapshots (with both Thingiverse syntax and native syntax ):

  1. Source Code:
    1. https://github.com/openscad/openscad/tree/gsoc2016

Note: This plan of future but not included in yet in final PR

You can report any issue that you found related to customizer at:

https://github.com/openscad/openscad/issues/1781

Click here to see final post

Advertisements

6 thoughts on “User Interface for Customizing Models ( Part 2)

  1. Thank you for your work, this is really awesome.

    Last thing I am missing from openSCAD is a possibility to re use the object cache between invocations on the CLI, maybe in form of an openSCAD daemon.

    Like

  2. I just checked out your branch and started playing around.

    I am on a notebook, and really have troubles setting the sliders to the position I want. They keep updating before I let go of them, so setting them to exact values is really a hassle – seems it will update after some time of no movement, which makes it hard to pin an exact number with my touchpad.

    Also when automatic preview is enabled, as soon as I set a value in the parameter view, it is reloaded and scrolls to the top. I have ~10 tabs with ~10 parameters each, so I have to scroll quite a bit when trying to set multiple parameters in the same tab. Would it be possible to leave the parameter view at its scroll position?

    Further I found, that my sliders with 0.1 steps only did 1.0 steps. 0.1 steps are working on thingiverse with a range like so [0:0.1:10].

    I am very interested in moving those features on, so let me know if I can help in any way – I can also make issues for this on github if you prefer,….

    Greetz,
    Chris

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s