## Introduction: Geology With Tinkercad CodeBlocks

In this project we will learn to geometrically analyze different types of crystal rocks (or minerals) and seek to replicate them using Autodesk Tinkercad Codeblocks. The inspiration for this project come to me when one of my students was trying to replicate a geode with Tinkercad Codeblocks for a biomimicry assigment.

Now let's go deeper into the subject!

## Supplies

Software CAM: Ultimaker Cura 3D (optional)

Hardware: 3D Printer (optional)

Material: PLA+ Filament (optional)

## Step 1: Understanding the Geometry of Rocks and Crystals

Many geometric solids actually occur in nature. Mineral crystals grow into regular, geometric shapes.

Tetrahedrons

Tetrahedrite forms regular tetrahedral shaped crystals. It was first described around 1845 in Germany and is used as source of copper. (del Court, 2014)

Cubes

Pyrite or “fool’s gold” in particular forms nice crystals. In the 16th and 17th centuries pyrite was used as a source of ignition in early firearms, creating sparks when stroked by a circular file. (del Court, 2014)

Bismuthalso tends to grow in the form of cubes that grow in steps towards its center, in geometry this phenomenon is known as a concentric pattern.

Octahedron

Magnetite is actually the most magnetic of any naturally-occurring mineral on Earth. By observing the attraction of magnetite to small pieces of iron, people in China during the 4th century BC and Greece in the 6th century BC first observed magnetism. (del Court, 2014)

Hexagonal Prism

Quartz crystals form hexagonal prisms. The long prism faces always make a perfect 60° angle and split light into a spectrum. (del Court, 2014)

The geometry of any crystal (in fact of any geometric pattern) is based on 3 basic principles:

• Shape: It is the base figure.
• Repetition: It is the number of times a base figure is "copied and pasted".
• Alignment: It is the order given to the copies of the original figure in a work plane.

## Step 2: Translating It to Tinkercad Codeblocks

These geometric shapes are very easy to recognize and (lucky for us) most of them are already preset in the Shapes or Primitives menu of Tinkercad CodeBlocks.

To select a new shape just drag it to the work area and click on the Play button to run the simulation and display the animation.

## Step 3: Primitive Shapes

Some geometric shapes that at first glance seem complicated, in reality it is just the repetition and change of position of the same base figure. Let's see how to do it in Tinkercad CodeBlocks:

Tetrahedrons

1. Drag and drop a pyramid block (form menu) to the work area.
2. Click on the "open more options" icon (right arrow).
3. Change the value of sides to 3 (this way we will get a 4-sided pyramid or tetahedron).

Cubes

1. The easiest figure, it is just a matter of dragging and dropping the cube or box block (form menu) to the work area.

Octahedron

1. Drag and drop a pyramid block (form menu) to the work area.
2. Add a move block (modify menu) and change the value of Z to 20 (this will move the figure 20 units upwards)
3. Add a new pyramid below the code.
4. Add a rotate block (modify menu) and rotate the X axis 180 degrees.
5. Add a create group block (modify menu) which will weld both pyramids together, forming an 8-sided figure (octahedron).
6. If you want to be more precise, you can add a scale block at the end (modify menu) and change the Z value to 0.7 so the figure will look more uniform.

Hexagonal Prism

1. Drag and drop a polygon block (form menu) to the work area.
2. Click on the "open more options" icon (right arrow).
3. Make sure that the value of Sides is set to 6.
4. You can add a scale block (Modify menu) and change the Z value if you want to change the length of the hexagonal prism.

## Step 4: Repetition

To repeat a figure multiple times in Tinkercad CodeBlocks we need to use the repeat "1" times block (control menu). However, before creating a repetition we must create a new object (Modify menu):

1. First drag and drop create new object blockfrom the modify menu in the work area.
2. Now just below that block drag and drop a repeat 1 times block from the control menu.
3. Choose any shape you want (from the shape menu) and insert it INSIDE the block repeat 1 times. You will see that the pieces fit together like a puzzle.

If you change the value "1" to any other number in the block repeat 1 times, the figure will be copied as many times as you decide.

However, even if you run the simulation, it will not be possible to see the changes in the previewer, why? because the objects are being copied and pasted right in the same position! (one above the other)... to see the changes you need to repeat and move them! as we will see in the next step.

## Step 5: Alignment or Arrays

First we must understand the types of alignments that exist:

• Linear or grid alignment: in which objects are repeated towards one or two directions to fill a space.
• Rotational alignment: in which objects spin around an axis of rotation, forming circumferences.
• Random alignment: in which objects fill a space by positioning themselves in different locations apparently randomly.

Now let's see how to do it using Tinkercad CodeBlocks:

Linear alignment:

1. First drag and drop create new object block from the modify menu in the work area.
2. Now we need to create a variable. You can drag the create variable block from the math menu and place it just below the previous block (keep the value 0).
3. Change the name of the variable (for easy identification) to any word you want such as "movement" to do this click on the drop-down menu in the block and select the option rename variable...
4. Now just below that block drag and drop a repeat 1 times block from the control menu.
5. Choose any shape you want (from the shape menu) and insert it INSIDE the block repeat 1 times. You will see that the pieces fit together like a puzzle.
6. Now below the previous block (but staying inside the repeat block) you will place a movement block.
7. Access the Data menu and you will notice that a new block is now created with the same name you gave to your variable.
8. Drag that block and place it inside the move block (it can be on X, Y or Z depending on which direction you want to move the figure).
9. To almost finish we will add a change element block (you find it inside the math menu) and in the drop-down menu of the block select the name of your variable.
10. It's time for some math! Drag an equation block (you find it inside the math menu with the symbols 0 + 0) OUT OF YOUR CODE, you can use any empty space in the work area.
11. Change the last 0 to any number you want, this will represent the units your figure will move.
12. To finish drag your equation block and place it after the "to" section of the change variable block over the 1 (to replace the number 1 with an equation 0 + n).
13. Finally, run the simulation and watch the magic. I know the first time is tedious, but it gets easier with practice.

Rotational alignment:

1. First drag and drop create new object blockfrom the modify menu in the work area.
2. Now we need to create a variable. You can drag the create variable block from the math menu and place it just below the previous block (keep the value 0).
3. Change the name of the variable (for easy identification) to any word you want such as "rotation" to do this click on the drop-down menu in the block and select the option rename variable...
4. Now just below that block drag and drop a repeat 1 times block from the control menu.
5. Choose any shape you want (from the shape menu) and insert it INSIDE the block repeat 1 times. You will see that the pieces fit together like a puzzle.
6. Now below the previous block (but staying inside the repeat block) you will place a movement block.
7. Change the value of the X or Y axis of the move block (to move the figure away from the center of the working plane or origin).
8. Add a rotate around block (you can find it in the modify menu) and change the X axis option to Z axis.
9. Access the Data menu and you will notice that a new block is now created with the same name you gave to your variable.
10. Drag that block and place it over the number just after the "to" option in the rotation block.
11. Now from the math menu drag a block "X:0 Y:0 Z:0 Z:0" and place it just after the rotation degrees option of the previous block (this way we make sure that the figure rotates around the center of the plane and not from its own center).
12. To almost finish we will add a change element block (you find it inside the math menu) and in the drop-down menu of the block select the name of your variable.
13. It's time for some math! Drag an equation block (you find it inside the math menu with the symbols 0 + 0) OUT OF YOUR CODE, you can use any empty space in the work area.
14. Change the last 0 to any number you want, this will represent the units your figure will move.
15. To finish drag your equation block and place it after the "to" section of the change variable block over the 1 (to replace the number 1 with an equation 0 + n).
16. Finally, run the simulation and watch the magic. I know the first time is tedious, but it gets easier with practice.

Random alignment:

Fortunately, this type of alignment is much easier than it looks.

1. First drag and drop create new object blockfrom the modify menu in the work area.
2. Now just below that block drag and drop a repeat 1 times block from the control menu (by changing the number you control the number of figures that will appear).
3. Choose any shape you want (from the shape menu) and insert it INSIDE the block repeat 1 times. You will see that the pieces fit together like a puzzle.
4. Now below the previous block (but staying inside the repeat block) you will place a movement block.
5. We will use a new block called "random between 0 and 10" you can find it in the Math menu.
6. Drag the block and place it just after the X coordinate of the move block. Repeat the action for the Y coordinate.
7. Finally it is necessary to define a range of numbers (or a range of positions in which our figures will appear randomly). For example if you would like the figures to appear all over the work plane, you can type -100 to 100 inside the block "random between..."

## Step 6: Hands in Action!

Now that you've learned the basics, it's time to put it to the test. Identify the geometry of the most popular crystals and use what you learned in today's lesson to try to replicate them.

Here are a few courses of action (hints):

Magnetite

• You will have to join two 4-sided pyramids to form a tetrahedron, which will be the main module to be repeated.
• Use a repeat block to multiply the number of shapes and mix it with a move block + range between 0 - 10 to position in different places the shapes.
• Try adding a scale block to change the sizes of the shapes.

Tetrahedrite

• Start with a 4-sided pyramid.Use 4 other pyramids to cut the corners of the figure.
• Repeat this composite figure several times on the work plane changing its sizes.
• Pro tip: add X, Y, Z rotation blocks and combine them with a range block (0 to 360) to rotate the figures randomly for a more realistic look.

Pyrite

• The simplest figure of all, it just uses boxes and repeating blocks to form smaller boxes around a large cube.

Volcanic Rock

• It looks difficult but it is not! Start with a large solid body (I recommend a sphere).
• Randomly place many small and medium spheres around the main body. Make sure to set it to "hollow" mode.
• Group everything together and watch as the small spheres remove chunks of the main body.

Quartz

• Create a hexagonal prism and align it to the Z-axis.
• Place a 6-sided pyramid on top of it
• Make a cut right at the tip of the pyramid
• Group everything together and use it as a module.
• Repeat the module using the repeat of rotation to spin towards the center of the plane.

Bismuth

• Complicated figure, it all starts with a cube.
• Now you will need 6 pyramids that will cut the sides of the cube to leave us only with the "frame".
• Repeat the frame several times towards its center decreasing the overall scale.
• In the end due to the primitive restriction (Tinkercad CodeBlocks only allows 200 primitives in the work plane) we will only be able to repeat the figure a couple of times, more than enough to achieve a great result.

Geode

• Cubes are its base figure
• Repeat the cubes around the center to form rings using patterns of revolution.
• Change the color of the rings to more closely resemble the actual colors of the gemstone
• At the end use a large box to cut the design in half (like a geode being cut in real life).

If you have trouble understanding the subject, I also leave you the links to my tests so you can replicate and experiment with them!

## Step 7: Export for 3D Printing

When finalizing your design don't forget to add a "create group" block to the end of the code, this way we make sure that all the pieces are together as one solid.

Go to the export menu and choose .stl (most common format for 3D printing).

## Step 8: Fixing for 3D Printing (Tinkercad 3D Designs)

Remember! it's very important that before 3D printing anything you must make sure that the model is feasible, in other words, that it complies with the following 3D printing rules:

• You cannot print models floating in space without a base or support.
• Angles that exceed 45 degrees will require structural support in the CAD software.
• Try to make the base of your figure as flat as possible to ensure good adhesion to the print bed.

In this case it is very difficult to take care of these rules when we are making random patterns. I recommend importing the .stl model into Tinkercad 3D Designs to fix it before printing, in this case:

1. I added a polyhedron in the center where it intersects all the shapes.
2. Then added a hollow cube underneath to make sure the floor is flat.
3. Finally grouped everything together and exported back to .stl format.

## Step 9: 3D Print It!

For this project we used the free CAM software Ultimaker Cura 3D with the following parameters:

• Material: PLA+ silk
• Nozzle size: 0.4 mm
• Layer quality: 0.28 mm
• Infill: 20% grid pattern
• Extrusion temperature: 210 C
• Hot bed temperature: 60 C
• Printing speed: 45 mm/s
• Supports: Yes (automatic at 45 degrees)