Creating and Using Reusable 3D Patterns Using Tinkercad Codeblocks

Ron Mourant
4 min readOct 24, 2018

One of the benefits of using tinkercad codeblocks is that you can easily create patterns that can be used to decorate your 3D prints. A good example of this is the Tea Light Holder:

Tea Light Holder (Lighted with a LED)

The basic pattern for this is simple and shown below as four holes.

Four-Holes-Pattern

I have stored the Codeblocks to generate the four-holes-pattern as a separate design. This way it can be duplicated and then used and modified as part of other designs.

Those not familiar with Tinkercad’s Codeblocks should see An Introduction to Tinkercad Codeblocks.

Here are the codeblocks that generate the four-holes-pattern shown above.

Codeblocks for the Four-Holes-Pattern

The Step button (at upper right) allows you to run your codeblocks and see the results on the workplace, one step at a time. Press the Step button to get started and then use the space bar to advance to the next codeblock.

Keep pressing the space bar until the count loop has executed four times. The workspace should look like:

Base yellow cylinder with four cylinders as holes.

The pattern that we want is the intersections of the holes with the base cylinder. At the present time, tinkercad’s Codeblocks does not support an intersection operation. Maybe someday. We continue with a work around to get the intersection.

The next codeblock, Create Group, subtracts the intersections from the base cylinder and then turns the remaining base cylinder into a hole. We call this the “BaseHole”. The result appears on the workplane and looks like:

BaseHole — Holes Subtracted from Base (Turned into a hole)

Now we add in a base again, this time making its color red. This appears on the workplane as:

BaseHole with New Red Base Cylinder

The next Create Group does the subtraction and gives us the pattern we want (four-holes pattern). It also turns the result into a hole as we requested.

We now have the Four-Holes-Pattern as shown above.

Using the Four-Holes-Pattern

Since the four-holes-pattern is stored as a separate design, you can duplicate it. In the duplicated design, add the codeblocks for your creation and then decorate it with the four-holes pattern. We illustrate this with the creation of the Tea Light Holder that is shown above.

The following codeblocks create the undecorated TeaLightHolder.

The result of running the codeblocks above is shown below:

TeaLightHolder — radius = 25mm height = 76mm

The base and sides of the TeaLightHolder are 2mm thick.

Now we use the Four-Holes-Pattern to decorate the TeaLighHolder. The Four-Holes-Pattern is vertical and we want it horizontal. To do this we rotate it around the X-axis by 90 degrees.

We also have to position the four-holes-pattern so it will intersect the wall of the TeaLightHolder. We move it in the Y and Z directions to do this. By using the one step at a time simulator you can see where this start position is:

Start Position for Four-Holes-Pattern

Here are the codeblocks for the beginning of the decoration process:

Creation of a Circle of the Four-Holes-Pattern as a New Object

A count codeblocks is used to put the nine four-holes-pattern in a circle around the bottom of the TeaLightHolder. Our TeaLightHolder now appears on the workplane as:

TeaLightHolder with Bottle Circle of the Four-Holes-Pattern.

Creation of the top-two circles for the four-holes-pattern is done by copying the CircleOfFourHoles object and raising it up the Z-axis. Here on the codeblocks to do that:

Copying the Bottom Circle of the Four-Holes-Design-Pattern

Our final step is to do the CreateGroup subtration operation on the TeaLightHolder.

Here is the decorated TeaLightHolder.

Decorated TeaLightHolder

The .stl and .zcode files can be downloaded at: Thingiverse.

--

--

Ron Mourant

TinyML, AI, Edge Impulse, Arduino, Raspberry Pi, Pickleball