Introduction:

Google Summer of Code, is an international software development program organized annually. Every year, thousands of students from all over the world apply for this life changing opportunity (in the literal sense) and only a fraction of them actually get to live this dream. I am one of them.

My GSoC project is called User Interface for Customizing Models. It is under the umbrella organization of BRL-CAD. OpenSCAD is an open source organization that serves a free software to create solid 3d CAD objects. OpenSCAD has in a way redefined how easy 3D modeling can be. But the Wikipedia article on OpenSCAD says that it is a non interactive modeler, but rather a 3D compiler based on a textual description language. Pay attention to the above line, it’s primarily what I’ll be talking about in this post.

What the guys over at Wikipedia said is true but their version of the truth needs a little filtration (rather trimming). OpenSCAD’s way of customization is interactive, just not through a graphical interface. And this contingency makes the whole 3D modeling thing a little less easy than it can be. But all of that is about to change. How? Just read the rest of the post and see for yourself.

Solid 3D modeling. That sounds like some serious business. But it’s just an awesome tool for making models pertaining to many uses (mostly 3D printing). And 3D printing as we can all agree upon is cool. 3D models can be created by anyone using OpenSCAD. OpenSCAD is as much for designers as it is for you and me. What else can most people agree upon apart from the fact that solid 3D modeling is cool? A graphical interface is simpler and more intuitive to use. There is a general aversion for typing commands in order to get things done. Simply put, more people have an inclination towards GUI.

This is something that OpenSCAD lacked. But the benevolent folks at Thingiverse.com found a way to help out the demographic intersection of GUI lovers and OpenSCAD users. The website provides an easy to use interface to customize models of OpenSCAD. All one needs to do is upload the OpenSCAD file. After uploading the file, what you’ll see can only be described as being magic. I’m kidding, it’s just very useful is all. The OpenSCAD’s script is used to make a form containing slide bars, text boxes, combo boxes, labels, etc all for the singular purpose of customizing models.

My GSoC project was to include similar functionality into OpenSCAD itself. Constantly having to upload files created in one software (OpenSCAD) to a website in order to customize your models can get a little problematic as one is uploading scripts without being able to confirm how the script will translate into a form on the site. Wouldn’t it be great if everything is at one place, the original place: OpenSCAD? Of course, it would.

My project intends to define a user interface to customize models interactively instead of having to modify them manually. It will enable the user to create the templates for a given model which can further be changed as per user’s requirements.

This project upon completion will allow the modelers to create generic models (templates) which others can then customize to cater to their own use.

Goals:

The major goals of My project are:

Syntax support for generation of customization form:

The customization form generated on Thingiverse is based on a certain syntax for both describing the elements in the form and providing a range of their values. In order to make this work in OpenSCAD as well, the same style of description and parametrization can be incorporated into OpenSCAD. Hence the user will be able to generate the customization form from within OpenSCAD by adding a few simple lines in the .scad file. Customization of the model from the form:

Once the form is ready, it must be able to customize the model as desired by the user. The changes made in the form should directly correspond to changes in the model itself. Enhancing the UI for the customization form:

The customization form is there to make the whole customization thing easy. And that implies that the form itself should also be easy to use. And this can be achieved by having a good and simple look to the whole thing.

Current State:

So I’ve cleared my GSoC mid-term. That means I must have tasted some success in regards to achieving some of the above-mentioned goals. The version of OpenSCAD I represent provides the syntax support for generation of the customization form and then some!

Unlike in Thingiverse where parameters need to be placed at the top of your script before the first module declaration, parameters in this version of OpenSCAD can be placed anywhere in the script, outside module declaration. This should be in the following form:

// variable description variable name = default value; // possible values

The variable description line is optional but is useful to give the user an idea of what the parameter defines.

Furthermore, it will make input widget for only those parameters that you want it to and not for every parameter there is in the script.

There are a couple of things that are different from Thingiverse but are a little more modest.

Variable names will not be automatically formatted to be more readable.For instance small_box_height will not be labeled “Small Box Height” on the form.

Unlike in Thingiverse where the possible values comment at the end is optional, this version of OpenSCAD requires you to have this comment otherwise, the widget for this variable will not be provided in the form. This is in accordance to what I discussed earlier i.e. the liberty to choose what variable will be having a widget in the form.

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

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:L] //labeled combo box for string Labeled_value="S"; // [S:Small, M:Medium, L:Large] Slider:

Only numbers are allowed in this one, specify any of the following: // 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

Future Scope:

The above section of this post described the current state of the project. I plan to include all the main features from Thingiverse and then add some more to make the user experience even better. Some of these features include:

Grouping of widgets based how the user wants to use them. The functionality of being able to export changes made in the form to a script (sort of like the inverse what we are doing). Enhancing the form UI. This one is a biggie, so pay attention. The current syntax is based on Thingiverse. But that need not be permanent. In the future, we can have a whole new syntax support in OpenSCAD for doing exactly what the current syntax does. This future inclusion would enable OpenSCAD to offer a far grander set of features than the present version does. This would also imply some improvement in the performance (as the current version is basically a detailed post-processing of the script).

Following is the syntax for how to define different types of widgets in the form with native syntax that we might support ( discussion regarding this syntax is going on, you can also be part of that discussion and give your opinion ):

Note: This is planned syntax for future but not included in yet in final PR

Drop down box: @Description("combo box for nunber") @Parameter([0, 1, 2, 3]) Numbers = 2; @Description("combo box for string") @Parameter(["foo", "bar", "baz"]) Strings = "foo"; @Description("labeled combo box for numbers") @Parameter([[10, "L"], [20, "M"], [30, "L"]]) Labeled_values = 10; @Description("labeled combo box for string") @Parameter([["S", "Small"], ["M", "Medium"], ["L", "Large"]]) Labeled_value = "S"; Slider:

Only numbers are allowed in this one, specify any of the following: @Description("slider widget for number") @Parameter([10 : 100]) slider = 34; @Description("step slider for number") @Parameter([0 : 5 : 100]) stepSlider = 2; Checkbox: @Description("Checkbox for boolean ") @Parameter() Variable = true; Spinbox: @Description("spinbox with step size 23") @Parameter(23) Spinbox = 5; Textbox: @Description("Text box for string") @Parameter() String = "hello"; @Description("Text box for vector with more than 4 elements ") @Parameter() Vector = [12, 34, 45, 12, 23, 56]; Special vector @Description("Text box for vector with less than or equal to 4 elements") @Parameter() Vector2 = [12, 34, 45, 23];

This is what future of OpenSCAD will look like.

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 ):

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

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