Monday, February 17, 2014

Creating a customizer file for Thingiverse.

A friend of mine wanted me to duplicate a movement tray for his war gaming figures.  These trays keep a bunch of figs together so that you can move the tray, instead of having to move a bunch of individual figs.

So I created an openscad file that looked like this:

difference () {

    cube ( [107, 53, 3], center=true ) ;

    translate ([0,2,1]) {
        cube ( [107-2, 53-1, 3], center=true ) ;

This created a 3D tray by creating a box shape and chopping out a slightly smaller block that is moved to one side and up a bit.

You work with vectors of [x, y, z] numbers because this is 3 dimensions or 3D.  There is a basic tutorial on openscad here:  There are many tutorials, but this one seemed to work for me.

And this is all fine and good, if all you wanted was that single movement tray.  But he wants to be able to build any number of different movement trays, for many different figures.  So I took the numbers and made them into variables and put the variables at the top of the file, and that allowed me to easily change the numbers to anything I wanted and the math is handled.

I had been seeing the customizer things on and I thought that this would be a great first try for this techniques.  All I had to do was put in some markup in comments around the variables like the following:

// Width of the tray as it faces the enemy?
tray_width = 107; // [50:1000]
// Depth of the tray away from the enemy?
tray_depth = 53; // [25:500]
// Edge height of tray?
edge_height = 3;  // [2:5]
// How wide is the edge?
edge_width = 2; // [1:5]

difference () {

    cube ( [tray_width, tray_depth, edge_height], center=true ) ;

    translate ([0,edge_width,1]) {
        cube ( [tray_width-edge_width*2, tray_depth-edge_width+1, edge_height], center=true ) ;

The comment just before each variable becomes the text in the customer for that control, and the range in the comment following the variable becomes the control type and range.  I just used sliders, but there are a variety of other controls you can use in your own customizer tags.  This is discussed here:  It  looks like you can even have controls in various named tabs, or create a hidden section so you can use variables that don't appear.

Then I uploaded the openscad file, added the customizer tag (this is important or you will not see the customer option for your thing), and a couple of other tags and was able to see the new object running in the customizer on thingiverse here:  I also created an stl file on my local system and uploaded that so that there was something for people to see.

There are some best practices to use here:
These tell you how to design for regular people, which is what these files are aimed at.  Anyone that is already advanced can already download your openscad file and configure the output anyway they like.


I took a second shot at this design, calling it the Easy Movement Tray.

This was after using the first tray designer to lay out a couple of trays.  I realized that for most people there was a much simpler way to do the design.

Instead of having to do all the measuring yourself, I allowed people to select a base size from a drop down list of sizes, then tell me how many figures wide and deep the tray should be.  I also put in a few little divots in the middle of the tray, between all the corners, for an easy way to see the sections where the bases should be.  This also helps to break up the large featureless flat plane.

I actually add one more mm to the base size, for base variation, so that 28mm becomes 29mm. After painting and flocking bases can be a little bigger than they started, so I wanted to compensate for this.   After that I calculate everything by the tray width and tray depth, just like the first tray.  I used a //[hidden]  tab for these variables, so that they wouldn't show up in the UI.

The main update I need to make to this file is to have a better drop down list of base sizes that reflect more sizes that people use in the real world.

No comments:

Post a Comment