Code your 3D designs with Tinkercad’s new Codeblocks app

Code your 3D designs with Tinkercad’s new Codeblocks app

Tinkercad released Codeblocks last June, and now that it's out of beta, Pioneer Pioneer Rob Morrill tells us how he uses it at St. Matthew's Episcopal Day School.

Tinkercad has brought coding to its 3D modeling platform with the introduction of the web app Codeblocks. Rather than drawing the design, as one might in a turtle art graphics environment, this is object-oriented programming, meaning that you place a predefined object on the workplane and then modify it. The basket in the example below consists of a six-sided torus shape that is repeatedly rotated up and around 27 times to form a circle.

01 codeblocks design
02 codeblocks project example 03

In traditional Tinkercad, you build models by dragging basic shapes like a box, cone, or wedge onto the workplane. Codeblocks is similar, but rather than dragging a shape out to the workplane and then resizing it, you drag a block of code for an object whose parameters you can adjust.

03 solid 01

Note that the shape loads on the workplane at X, Y, Z coordinates 0, 0, 0. This means that half of a 20 x 20 x 20 millimeter cube will be underneath the workplane. Red, green, and blue lines delineate X, Y, and Z respectively. Following the Add Box block with a purple Move block with a value of 10 for the Z axis will raise the cube to sit on the workplane.

04 solids 02

Here, a box and a sphere have been added and raised in the Z axis, while the cone was not only raised and rotated 180 degrees, but also turned into a hole.

05 adding solids

Adding a Create Group block groups these three shapes together.

06 adding solids 01

The power of Codeblocks becomes apparent the more you take advantage of coding aspects like loops and variables to control and iterate your designs. Here is a simple loop that uses a variable to rotate rings around 0, 0, 0.

07 rotation

This laser-cut cardboard disk helps students understand the polar and Cartesian movements in the Codeblocks environment.

Add a torus shape to 0, 0, 0.

08 quadrants 03

Move the torus in a positive Y direction.

09 quadrants 06

Rotate the torus around 0, 0, 0.

10 quadrants

Add, move, and rotate a second torus.

11 quadrants 02

Add, move, and rotate a third torus.

12 quadrants 05

Repeat 8 times.

13 quadrants 04

This basket is made up of hearts that have been duplicated and rotated.

14 codeblocks and tinkercad 02

The export button allows you to export as STL or OBJ files for 3D printing, but you can also export the design as a “Part”.

15 export

When you save a Part, the design becomes available back in traditional Tinkercad, where you can resize it and add it to other creations.

16 create a part

The red elements of this design have been added to the original blue Codeblocks design using traditional Tinkercad.

17 codeblocks and tinkercad 01

From traditional Tinkercad, you can also export the design in SVG format, which then allows you to paper or laser cut it.

18 products 03

These earrings were designed in Codeblocks and then laser cut.

19 products 01

The sides of this lamp were designed using a combination of traditional Tinkercad and Codeblocks.

20 products 02

This sign uses a combination of traditional Tinkercad and Codeblocks.

21 codeblocks and tinkercad 03

This clock’s face was designed in Codeblocks and laser cut.

22 products 04

For a good introduction to generative design, see “Some Thoughts on Generative Art” by Anders Hoff, and watch Kate Compton’s presentation “Generative Art (and Games and More)” from JSConf Iceland.

JSConf Iceland 2018
Watch the video

Codeblocks also makes it easy to experiment with generative design. The building heights in this cityscape and the ridges in this Martian crater were randomly generated.

23 parametric 01
24 codeblocks project example 02
25 codeblocks project example 01

Another great feature of Codeblocks for teachers and learners is the ease with which you can comment on your code. This helps students make their thinking visible, which aids both in their own metacognition as well as in allowing teachers to gain insight into their understanding.

26 blocks

Access Codeblocks either by going to traditional Tinkercad and finding the link, or by going straight to: https://www.tinkercad.com/codeblocks

27 codeblocks

Codeblocks’ opening page contains starter projects that let you see how a variety of blocks can be used in different ways.

28 starters

Here is a quick video on a “Codeblocks Intro”:

codeblocks
Watch the video

And here is a longer tutorial: “Getting Going with Codeblocks”:

codeblocks-1
Watch the video

Explore, have fun, and share your designs.

Learn more about software