Introduction: Designing With Algorithms in Tinkercad

About: Tinkercad is a free and easy, browser-based 3D design and modeling tool for all. Tinkercad allows anyone to imagine anything and then design it in minutes.

This has been written by the Tinkercad team at Autodesk as a teacher-led resource to support the 'Hour of Code™'. The Hour of Code is a nationwide initiative by Computer Science Education Week [csedweek.org] and Code.org [code.org] to introduce millions of students to one hour of computer science and computer programming. The 2019 Computer Science Education Week will be December 9-15, but you can host an Hour of Code all year-round.

Recommended grades: 6-8

Skills taught:

  • Create a computer program that includes variables for control points and count-controlled loops
  • Fix a problem in an existing program in order to create something new
  • Describe choices made during program development using code comments
  • Compare tradeoffs associated with computing technologies that affect people's everyday activities and career options

Lesson overview:

Can coding enhance human imagination? During this lesson, students will consider how and why humans collaborate with computers to make things like art, buildings, and products. Students will also analyze, create, and remix interesting algorithm components using Tinkercad Codeblocks, including variables for control points and count-controlled loops. At the end, they will have a 3D model of a snowflake from code.

In this lesson students will:

  • Discuss and debate an issue of human and computer interaction
  • Recognize, define, and solve computational problems in a snowflake design in order to personalize it
  • Explore the use of control structures to set parameters, allowing students to compute more design iterations quickly and efficiently
  • Communicate clearly and express themselves using code and CAD
  • Make interesting, code-generated snowflake designs that they can share through 3D printing, making GIFs, or rendering images

Estimated instructional time: 60 minutes

Materials: computers, internet, Tinkercad (a free, easy-to-use, web-based 3D CAD design tool); optional, but useful: 3D printer, color printouts of the Codeblocks used in this lesson or this images folder, as well as teacher notes (see Step 8), and this slideshow.

Step 1: Build Some Context Around Co-creating With Computers (Optional)

Imagine your students are about to design something new, but instead of starting it based on what they already know or ideas that are in their minds, they could tell a computer what they want to make, and it would collaborate with them in their creation. Would this enhance their creativity, or would it hinder their imagination?

...And does the thought of this just totally freak you out?

Fear not (at least about teaching this lesson!) We have created a handy cheat sheet for you in order to help you and your students explore the issue of automation and how it is impacting the world in new ways, as well as some information on creating art with algorithms, featuring the algorithmic artist Nettrice Gaskins (whose work and image are included in this step and in the slideshow.)

The cheat sheet referenced here also includes an exciting debate activity to guide you and your students in processing all this information together.

Other things to explore before the Hour of Code

The inspiration behind Hour of Code is to "demystify" computer science, to show that anybody can learn the basics, and to broaden participation in the field of computer science.

In launching this lesson, you might share this slide show, which includes images and definitions of key words like automation,algorithm, variable, control structure, parameter, and count-controlled loop.

Your students can create more playful computer programs (which also build their knowledge about how algorithms can be used to make things) by incorporating control structures. Students can also make their algorithms more powerful and interesting by adding components like count-controlled loops.

The Codeblocks scripts for making snowflakes included in this lesson can lead your students through this type of iterative design process. And the best part is that they'll make a cool artifact of their learning when they're done!

Some educators choose to launch Hour of Code with their students by sharing a quick, inspirational video. Others front-load the hour by pre-teaching the context around coding during a lesson before the actual coding activity. Some schools or teams of teachers organize Hour of Code as a daylong (or even week long!) interdisciplinary activity.

The slideshow included in this lesson could be appropriate to discuss within the context of science, math, humanities, or art.

This lesson is aligned with the CSTA K-12 CS Standards and the ISTE Standards for Students.

Ready to start coding in CAD?!

Are you completely new to Tinkercad Codeblocks? Check out this Quick Start Guide to learn everything you need to start teaching with Codeblocks. In addition, these Code blocks starter activities are a great way for your students to get acclimated before embarking on the snowflake design.

The next step launches into the coding part of this lesson. If you think you may need additional support in getting started with Tinkercad Codeblocks, skip down to Step 7 for some more tips and more resources. Tip #1: Don't overthink it!

Even if you and your students only make it through the next step during the first hour, it's okay as long as everyone had fun and learned something new. There are so many more hours to code and CAD together!

Step 2: Play With Variables by Engineering a Personalized Snow Flake

Learning is always more fun when students can put themselves into the project. The Codeblocks scripts included in this step will enable your students to create a snowflake that includes text that they can easily modify to personalize their design... however there is a hitch: if the word they include goes beyond five letters, the design needs to be fixed in order to be legible (and also to be able to be 3D printed as one part.)

This is an interesting design challenge that can quickly engage students in problem-solving, while also exposing them to the concepts of control structures and parameters through playing with variables and other components of the algorithm.

Once they are logged in, they can go to the Codeblocks workspace by scrolling down and clicking "Create your first Codeblocks design".

When they are inside the Codeblocks editor, they can copy the scripts below to make a snowflake. (All of the Codeblocks scripts referenced in this lesson are included as a printable PDF at the end of the lesson, as well as in a shared folder of images.)

In attempting to modify the design to add different text, students should notice how the variables for control points at the top can be adjusted to easily make changes to the design. This is a good example of how beginning with clear goals and parameters can make a design more flexible and capable of iteration.

Provide a bit of guidance and structure

It may be best to have students work in pairs as they explore Codeblocks for the first time, so that they can check each other's mistakes and talk about what they are noticing each block is doing. (This also means fewer questions for you to answer as you are learning yourself!)

Some pointers for you:

  • One thing students might find tricky about copying the scripts from the images is that once one of the Shapes is added to a script, the word "Add" appears, as well as settings for changing the color or turning the shape into a Hole.
  • If you are printing the scripts on paper, using color ink is best. If that is not an option, you might just share the link to the folder of images of the Codeblocks scripts with students and have one student in the pair keep the scripts open on one laptop, while they use another to code. If there isn't one laptop per student, it is also possible to adjust the windows so that both Tinkercad and the image file are open at the same time.
  • Please do not use this Instructable as your primary source for the Codeblocks scripts! Please do use the images folder or the printable PDF at the end of the lesson - this will make coding MUCH easier!
  • Encourage students to give a name to each new Object they create. They should also do this with the Variables that are preset to 'item.' Not only is this a good organizational skill that is important in CAD, it also makes plugging Data into Codeblocks much easier.

Assessment and sharing

Encourage students to modify and remix the Codeblocks - and tell them not to worry if something breaks! They can always fix it. Their designs will also be saved in their Tinkercad accounts in case they want to return to them for more tinkering.

You might circulate the room and ask students questions as a means of formative assessment. The most important part is that they have the chance to play, imagine, design, and share their thinking.

Depending on your students' age level, familiarity with block-based coding, and engagement in the activity, you may extend this exploration and hold off on the following steps until the next lesson.

In order to check for understanding at the end of the lesson, you could have students add comments to their Codeblocks that explain their theories about what the blocks in the existing design are doing, and their choices in modifying the program. They could also record a GIF of their design to share their work. See Steps 3 and 5 for more info on this.

Step 3: Get to Know the Components of a Code-generated Design

What is a snowflake? When people say snowflake, they often mean snow crystal. Flakes can be the fluffy stuff that falls from the sky or a single crystal of ice, within which the water molecules are arranged in a precise hexagonal array. The latter is the radiant, six-fold symmetry that is the inspiration for the Codeblocks scripts in this lesson.

However, in adjusting the parameters in the last step, your students may have altered the snowflake's natural composition by changing the number of rays in the snowflake from six. Don't worry! Mother Nature forgives you.

In building the next snowflake design, you can encourage your students to continue to play Frankenstein, because the control points to the algorithm are also clearly laid out in the first script.

Using code comments

As your students are building their second snowflake by following the provided Codeblocks scripts, they should use the Step button (next to the Play button) to analyze what each individual block is doing. They should also document their thinking by adding comment codes, similar to what's pictured below.

The Comment block can be found in the Markup section of the Codeblocks panel.

The following are code comments for two key components in the second snowflake algorithm: control points and a count-controlled loop.

Need a closer look? These images are also included in the teacher notes document at the end of this lesson. At the end of the lesson, you will also find the complete Codeblocks scripts for the second snowflake in the student handout and images folder.

Creating variables for control points

Making a pattern with a count-controlled loop

Depending on the enjoyment level that you are sensing from students in your request that they write code comments to explain what is happening during each Step of the design, you might loosen up with the block-by-block directive and just ask that they write at least one comment at the end of the script to show their thinking. (HINT: Hour of Code is supposed to be fun.)

Step 4: Remix a Snowflake Design or Create Your Own

Once students have puzzled through the essential elements of the existing snowflake designs, it's time for a remix!

Let your students unleash a blizzard of creativity in imagining what they can make, by further modifying the algorithms, or even by combining elements of both into a design that is uniquely their own.

If your students need some visual inspiration, have them check out the work of this real-life "snowflake designer."

Or they could read about algorithmic artist Nettrice Gaskin's advice to students who are interested in creative coding: "Just make stuff; do stuff. Mess with the code."

Step 5: Make a Snowflake GIF


Are your students in love with their snowflakes? With just a tad more technological magic, you can help them bring their designs to life.

For near-instant gratification, your students could make GIF recordings of their Code-CAD creations. This can be done inside the Tinkercad Codeblocks editor by hitting the Share button and then choosing to "Save Gif" in the next screen. Make sure you run it first in the editor. (Note: It takes a few minutes for your GIF to package and download. Totally worth the wait!)

Students could also communicate what they learned with you during Hour of Code by adding a message block at the end of their program.

As their proud teacher, you might also ask permission to share some of their work yourself - in the spirit of "demystifying coding." (If you post on social channels, please tag us @tinkercad, so we can rejoice with you! It's our first Hour of Code too!!!)

Step 6: (Optional, But Fun!) Make It Real

If you and your students have access to a 3D printer or other fabrication equipment, their code-flakes could be transformed into ornaments, jewelry, and more.

The easiest way to do this would be to export their code-generated designs into their Tinkercad Parts Collection. By making the design a Part, students can then easily modify the design in the original Tinkercad 3D editor, for example, by adding a Torus shape (for attaching a hook to a 3D print) or a base (to make a 3D print more stable if your students go sculptural in their design.)

Students could also keep the design more 2D and laser cut it or make it into a sticker! For more info on how to make an .SVG from your Codeblocks design, read this Tinkercad blog post.

If your students are 13 or older, this could also present the opportunity to forge a pathway from Tinkercad to Fusion 360 by using the 'Send to Fusion 360' workflow with a simple click of a button!

Students could then show off their designs in a whole new light by creating amazing images with Fusion 360 rendering.

Step 7: Getting Started With Tinkercad Codeblocks

If this is your first time teaching a project that integrates CAD and code, here are a few helpful hints to get you started:

For more tips from our awesome Tinkercad community, here are some good reads about how they are using Codeblocks:

An Introduction to Tinkercad Codeblocks

Code Your 3D Designs with Tinkercad's New Codeblocks

And for more information on managing your classroom for making, how to assess a 3D design project, and more, please check out: How to Bring Tinkercad into Your Classroom.

Step 8: Celebrate!

Kudos to you and your students for braving the algorithmic elements of snowflake-designing! We really hope you had fun!!!

If you haven't yet taught this lesson, but are instead looking to stock up on all the resources you need to make Hour of Code super cool for your students, you're in the right place.

At the end of this step are PDFs you can print for the Codeblocks scripts we used, teaching notes, and a certificate for your students!

And here is a link to the folder with images for all of the Codeblocks scripts from this lesson: Codeblocks Images

Also, don't forget about the slideshow.

After your celebration is over, please "be back again someday!" You can let us know how it went by leaving a comment or sharing your students' creations.