# 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.