Assembling a Rocket with Codeblocks — Part 2

We will use these codeblocks to assemble the rocket from its bottom to its top. Assembling from top-to-bottom allows you to inspect and possibly debug whenever a new shape is added.

Start a new Codeblocks project.

The first shape to be added is a Cone. The Cone is turned into a “Modified Cone” by setting its Top Radius to 8. (3D Printing Consideration: Make the Bottom Radius larger. This helps the rocket have a firm fit to a 3D printer’s surface.)

I set the Bottom Radius to 18. Here are the codeblocks for the first (bottom) part of the rocket.

In the Comment code block, are 1) where Codeblocks placed the bottom of the shape on the Z-axis, 2) Where you want the shape to be placed on the Z-axis, and 3) the number of units the shape’s bottom has to be moved up the Z-axis.

Codeblocks places a shape’s center point at x=0, y=0 and z=0. Since the truncated cone’s height is 6, its bottom is at z = −3 and its top is at +3. We want the bottom of the cone to be placed on the workplane’s surface. The Move codeblock will raise it 3 units along the Z-axis.

Press the Run button to see the simulated animation and the cone on the workplane.

Truncated Cone with its bottom sitting on the workplane.

The second part of the rocket is an upside down star. Its height is 3 and we place it from z=3 (bottom) to z=6 (top). This makes it overlap with the top half of the truncated cone. Here are its codeblocks:

Press the Run button and you can see that part of the upside down star has been hidden by the truncated cone. This is what we want. It creates upside down fins (sides) as shown below.

We are now ready to add the rockets’s body. We want the bottom of the rocket’s body to be placed at z=6. Here are the codeblocks:

The partially completed rocket now looks like this after pressing the Run button.

We now want to add fins to the rocket’s body. We use a star with a height of 30 to do this. The bottom of the star will be placed at the bottom of the rocket’s body (z=6). The star and the rocket’s body will overlap along the Z-axis from Z=6 to Z=36.

Here are the codeblocks to add fins to the rocket’s body.

Press the Run button. The overlapping of the rocket’s body and the star hides part of the fins. Again this is the effect we want. Cool!

Only two more parts to add. We make a truncated star be a connecting part with a bottom radius of 8 and a top radius of 5.5. This connector is placed at the top of the rocket’s body (Z=96).

On top of the connector the Nose Cone is added. Since the height of the connector is 10, the Nose Cone’s bottom is placed at Z=106. We used a Parabolid shape for the Nose Cone as discussed in Part 1.

The codeblocks for adding the connector and the Nose Cone are below:

Press the Run bottom to see the complete rocket.

Nice!

Combine the Six Shapes into One Object

When assembling a group of codeblocks, You can put them in a “container” codeblock to combine them. The Create New Object codeblock is used for this.

Go to the Modify group and drag in the Create New Object codeblock. Make it the first codeblock. Click on its pull-down arrow and rename the variable to “rocket”.

Codeblocks automatically creates a variable with the name “rocket” and adds it to its list of variables (Click on the Variables group to see it.)

The Create New Object codeblock works in connection with the Create Group codeblock. When a Create Group codeblock is executed it combines all the added shapes after the Create New Object codeblock and ouputs one object.

All the codeblocks are shown below.

Tinkercad allows to export an animated .gif file

Click of the Share button (top-right)to get:

Press the Save Gif button. Tinkercad places the .gif file in your downloads folder.

Below is the .gif file for the rocket being assembled.

3D Printing

After running the above code blocks, press the Export button to get:

Selecting STL will generate a file named: “ProjectName”.stl. The file is put in your Downloads folder.

The .stl file is used by a slicer program to generate .zcode for a 3D printer.

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