# Tinkercad introduces their Shape Scripts API

The founders of Tinkercad launched their revolutionary CAD platform back in 2010, at a time when they saw that most 3D modeling tools being used then to create 3D printed models were too complex for average users. Their goal was to create a tool that does not require engineering background to use. They’ve been wildly successful at this, creating a radical new cloud-based, true solid-modeling CAD platform that is easy to use and fast to learn, yet very powerful.

And it just became more powerful, as they have introduced their Shape Scripts API.

Now, I admit I’m going to struggle explaining this in much detail, as I’m neither a mathematician nor a CAD expert. I’ll do my best at introducing it and letting the CAD blogs get into the nitty gritty.

Basically, a Tinkercad user can now write “shape scripts” right inside the Tinkercad editor on the browser, which are then executed on the powerful Gen6 geometry kernal on Tinkercad’s server cluster. In developing this function, ease of use was important, in line with their goal of keeping things simple. So they chose the commonly used language of Javascript, which makes it easy to access the new computational power available.

But what is a shape script? It is another way to create a three dimensional shape; rather than create it by hand (mouse, tools, etc), you create a shape by writing mathematical instructions for that shape in a script that you enter into the Tinkercad editor. Any shape you create–and you can create groups of shapes–becomes a solid in Tinkercad, and will be recomputed as required.

Here’s an example of a script that creates a tetrahedron, also known as a pyramid with a triangular base:

function process(data, params) {
var angle = 2*Math.PI / 3;
var h = Math.sqrt(2) * r;

var sides = [];
for (i = 0; i < 3; i++) {
var x = r * Math.cos(i * angle);
var y = r * Math.sin(i * angle);
sides.push([x, y, 0]);
}
var peak = [0, 0, h];

var mesh = new Mesh3D();
mesh.triangle(sides[0], sides[2], sides[1]);
mesh.triangle(sides[0], sides[1], peak);
mesh.triangle(sides[1], sides[2], peak);
mesh.triangle(sides[2], sides[0], peak);

return Solid.make(mesh);
}

That sets the tetrahedron at a specific size, which you can modify in Tinkercad. But you can also control the various values used in creating the shape adding custom parameters. Once added, these parameters become accessible in the Tools menu as you see in the screenshot:

Once you get the basics down, you can start to create some interesting math art, by adding twists and rotations and other variables:

Even with my lack of expertise in this area, as I read through the documentation and tutorials, I was able to easily understand the concepts and even much of the details. I’ve seen and written alot of documentation, and my hat is off to Tinkercad for the terrific job they did in their instructions. Honestly, it’s some of the best I’ve seen.

Shape scripting is available to paying members of Tinkercad, but full use of it is available on a trial. Pricing runs from \$9.95/month to \$49.95/month, depending upon the number of designs you’ll create and keep, and members on your team. The lowest level allows five team members and 100 designs, but keep in mind that you can create an unlimited number of new designs as long as you delete old ones to stay under your storage limit.

### 4 Responses to “Tinkercad introduces their Shape Scripts API”

1. Ivan Pope says:

I would hazard that, as someone who will never script a tetrahedron in Javascript, it would be a lot more useful to concentrate on allowing easy sharing of scripted shapes. They focus on making it easy to script right in the app, and that’s got to be good for coders. But for the rest of us, how about a system for making shapes available, even if pay for or subscription.
I see the creation of scripts could get expensive very quickly. I’m not sure this model is sustainable in the longer term – I”ve never known a system where you are restricted in the code you can store.

• mark says:

“I see the creation of scripts could get expensive very quickly. I’m not sure this model is sustainable in the longer term – I”ve never known a system where you are restricted in the code you can store.”

I’m not following. Creating scripts isn’t costly. There’s no charge for scripting, other than being a paying Tinkercad member. As for sharing, the Maker community is a very sharing group of people and I’m sure scripts will be very much freely shared among members.

And I’m not sure what you mean by “restricted in the code you can store.” There’s no restriction on code. There is a number of models you can store on Tinkercad, based upon your membership level, which is a valid subscription model. But I think you are trying to say something else.

2. Ivan Pope says:

Creating scripts isn’t costly. There’s no charge for scripting, other than being a paying Tinkercad member.

“Pricing runs from \$9.95/month to \$49.95/month, depending upon the number of designs you’ll create and keep, and members on your team. The lowest level allows five team members and 100 designs, but keep in mind that you can create an unlimited number of new designs as long as you delete old ones to stay under your storage limit.”

OK, I exaggerated – not paying attention to the details. But it is a cost/limit on scripting.

• mark says:

“OK, I exaggerated – not paying attention to the details. But it is a cost/limit on scripting.”

No, there is only a limit to the number of models you can store online at any one time, not scripts, depending upon your membership plan. One hundred models for ten bucks a month seems pretty generous to me.