How to Make and Assemble Objects in Tinkercad’s Codeblocks: Divide, Simulate, Assemble (DSA)

If you are not familiar with Tinkercad’s Codeblocks see An Introduction to Tinkercad Codeblocks. Objects in Codeblocks may be considered to be parts. To illustrate this, consider designing a wrench. In an excellent tutorial, using standard Tinkercad, Dibya Chakravorty divided a wrench into three parts (a Ring, a Handle, and a Jaw).

Below, Codeblocks are used to design and simulate the parts of a wrench. Assembling the parts into a wrench is also done using Codeblocks. This has several advantages as compared to using standard Tinkercad.

  1. Codeblocks includes a simulator. You can press the Run button for an object (a part) and see if it is what you expect.
  2. Many of Codeblock’s shape objects include parameters. The value of a parameter can be easily changed.
  3. You can adjust the design of a part by using the simulator in connection with changing parameter values.
  4. Codeblocks’s simulator allows you to visualize the assembly process.

Here are the codeblocks for the ring of the wrench.

Codeblocks to create the Ring.

The cylinder with Radius 6.25 was turned into a “hole” object (by clicking on the striped-circle icon). This means it is subtracted from the cylinder with Radius of 12.5. Press the Run button to see the Ring being created.

You can create a .gif file of this simulation by pressing the Share button.

Ring being created.

Here are the codeblocks for the jaw of the wrench.

Codeblocks to create the Jaw.

Again, a “hole” shape (the polygon) is subtracted from a cylinder. From the simulation you can see that the subtraction is not done until the polygon’s modifiers (Scale, Move, and Rotate) have been executed.

A polygon shape is resized by using a Scale codeblock. By changing the Scale values and the y-value of the Move codeblock, you can create a set of wrenches!

Parts can be 3D printed as prototypes. This allows real-world testing and viewing. Printing just the Jaw instead of the complete wrench can save time and material.

Jaw being crated.

The third part needed for the wrench is a Handle. This handle is so simple that it does not need to be a separate object. Here is the codeblock that creates the handle.

Codeblock for Handle.

The assembly process involves moving the Ring to the left along the x-axis and moving the Jaw to the right along the x-axis. The idea is to have the handle overlap a few millimeters with the Ring at its left-end and with the Jaw on its right-end. Then Codelocks will apply the addition operation to combine the three objects into one object.

Moving the Ring and Jaw

At the end of the codeblock statements to create the Ring (see above) the following was added.

At the end of the codeblock statements to create the Jaw (see above) the following was added.

These statements make the handle’s left-end overlap with the Ring and its right-end overlap with the Jaw.

Here are the codeblocks for the assembly of the wrench.

Codeblocks to assemble the wrench.

The entire codeblocks to create a wrench are shown below.

The wrench being assembled is shown below.

The height of the wrench is 4 mm. Codeblocks places objects with their center at x=0, y=0, and z=0. The final Move codeblock moved the wrench up 2 mm to place it on the workplane surface to facilitate 3D printing.

Question

One might expect the Move codeblocks for the Ring and Jaw to be placed after each object was added in the assembly process. I tried this but the simulator showed it did not work properly. Since Codeblocks is still in Beta, this may be changed in future versions.

Thingiverse

You can download the .stl and .gcode files for the wrench at: https://www.thingiverse.com/thing:3112908/apps

Happy dividing, simulating, and assembling.

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