User Interface for Customizing Models

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.

 

image.J842JY.png

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:

  1. 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.
  2. 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.
  3. 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:

Screenshot from 2016-07-04 17:44:30.png

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:

Screenshot from 2016-07-04 17:49:40
Output of Dropdown box syntax.
Screenshot from 2016-07-04 17:50:08
Output of slider, checkbox, textbox, etc.
  1. 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]
  2. 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]
  3. Checkbox:
    //description
    Variable = true //comment
  4. Spinbox:
    // spinbox with step size 23
    Spinbox= 5; //23
  5. 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
  6. 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:

  1. Grouping of widgets based how the user wants to use them.
  2. The functionality of being able to export changes made in the form to a script (sort of like the inverse what we are doing).
  3. Enhancing the form UI.
  4. 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

Screenshot from 2016-07-03 20:29:19

  1. 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";
  2. 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;
  3. Checkbox:
    @Description("Checkbox for boolean ")
    @Parameter()
    Variable = true;
  4. Spinbox:
    @Description("spinbox with step size 23")
    @Parameter(23)
    Spinbox = 5;
  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];
  6. Special vector
    @Description("Text box for vector with less than or equal to 4 elements")
    @Parameter()
    Vector2 = [12, 34, 45, 23];

 

Screenshot from 2016-07-04 21:48:58.png

 

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

 

This is what future of OpenSCAD will look like.

Click here to see New Features

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. Mac:
    http://files.openscad.org/snapshots/OpenSCAD-2016.07.15-gsoc2016.dmg
  2. Window:
    1. 32 bit:
      http://files.openscad.org/snapshots/OpenSCAD-2016.07.15-x86-32_gsoc2016-Installer.exe
    2. 64 bit:
      http://files.openscad.org/snapshots/OpenSCAD-2016.07.15-x86-64_gsoc2016-Installer.exe
    3. Zip files
      http://files.openscad.org/snapshots/OpenSCAD-2016.07.15-x86-32_gsoc2016.zip
      http://files.openscad.org/snapshots/OpenSCAD-2016.07.15-x86-64_gsoc2016.zip
  3. Source Code:
    1. https://github.com/openscad/openscad/tree/gsoc2016

 

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

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

Advertisements

23 thoughts on “User Interface for Customizing Models

  1. I just saw this come up on #openscad on freenode. I wanted to say, Fantastic work! I can’t wait to see your repo pulled back into the main openscad repo!

    Like

    1. Thanks, buddy. It would be great to get your feedback on it and how it can be improved for better user experience. I think new binaries would be ready soon with the feature i.e. pagination of parameters and many more features to come.

      Like

  2. Hi Amarjeet i’m getting a syntax error can you please help?

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

    ERROR: Parser error in file “C:\Program Files (x86)\OpenSCAD”, line 20: syntax error
    ERROR: Compilation failed!

    Like

  3. Hi,
    Awesome, I was waiting something like that for my Ultimate Box Maker.
    I just downloaded and tried it right now, already working with some options.

    I will test it deeper, I really wish to make all the box and panel maker working with.

    Thanks a lot Amar.

    Like

  4. Hey, nice work. Formerly, I made custom GUI for the openscad parameters using PyQt5, but this is way better than my idea. One thing, Textbox doesn’t seem to work nicely with the non latin language especially Korean (I am using text module for the Korean).

    Like

    1. Thanks Kim, for reviewing it. And I think there was a small bug related to text box when these binaries were made which was corrected later, When I found it will testing the code.
      I will talk about support for Non-Latin languages with my mentors.

      Plus If you found any new issues or feature that could be part of this project do tell us.

      P.S You can also check out https://amarjeetkapoor1.wordpress.com/2016/07/18/user-interface-for-customizing-models-part-2/ (although binaries are not available for these but you can build it from source at https://github.com/openscad/openscad/tree/gsoc2016

      Like

  5. Very, very nice! Big Thanks!
    I use openscad and very needed in this functionality.
    On windows it works perfectly! Now i will wait functionality about groupping parameters.

    Like

    1. Thanks karijin for reviewing.

      We can add parameter to more than one group by making it global but If you want to add parameter to some groups not all then there is no option at present.

      Above feature and many more features that we had thought about will be added once our native syntax gets finalize.

      Like

  6. One suggestion: It would be nice to be able to save and load a set of parameters, so I can have different preconfigured sets easily available.

    As the parameters probably already exist in a some kind of memory structure, saving and load from file shouldn’t be that hard. Just a simple list, for example:

    parametername1=value
    parametername2=value

    Like

  7. Thanks for a marvelous posting! I really enjoyed reading it, you are a great author.
    I will be sure to bookmark your blog and definitely will come back later in life.
    I want to encourage continue your great posts, have a nice holiday weekend!

    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