Ho to Use Tinkercad Codeblocks to Create a 30 Design

Tinkercad has been the go-to 3D design application for Elementary and Middle School students (and a great starter 3D design application for high school students ) for almost as long as 3D Printers have been in schools. A recent addition to their design tools is Codeblocks, a Scratch-like programming language that allows students to create 3D objects through math and coding. In this workshop, participants will learn the basics of coding their own objects using variables, loops, and commands that allow the creation and manipulation of objects within Tinkercad. We will demonstrate how to export creations for 3D printing or fabrication on 2D tools such as laser cutters or desktop paper cutters and plotters.

Agenda and Links

  1. Introduction
  2. Logging in and playing around in tinkercad.com
    1. The Workplane and changing your view
    2. Placing, resizing, and moving objects
    3. Grouping objects
  3. Coding 2D Projects in Codeblocks
    1. "Logo-ish" 2D Shapes
    2. Fabricating Tips
  4. Coding 3D Projects in Codeblocks
    1. "Logo-ish" 3D Shapes
    2. Engineering 101 – Modeling real world objects in Tinkercad / Codeblocks
  5. Fabrication Tips
  6. Resources

1. Introduction

Hi! Welcome to my workshop!

My name is Kris Swanson, and I like to make things and to help others make things. My goal is that two hours from now you will be comfortable making some great things using Tinkercad and Codeblocks.

I am an Innovation Specialist at Pine Crest School's Boca Raton Campus, where I work with PK-8 students and teachers to integrate making, innovation, and entrepreneurship with PC's standard curriculum. A large part of my job is figuring out what tools (from scissors, hammers, and powertools to CAD and 3D Printers) and materials are the best fit for students and teachers to create amazing things. Over the years, Tinkercad has been an important part of that toolset, and over the past year Codeblocks has seen more and more use in our Innovation Labs.

My goal is to put everything you need to get started on this webpage. We will follow through it as we progress through the workshop. Everything will stay here for you to access when you get home (and much of what you do over the next few hours is pushed out by the next four days of FETC awesomeness!).

I'll make the same suggestion to you that I make to all my students – if something doesn't make sense, just ask! Start by asking your neighbor. Sure, you probably don't know them yet, but you might end up with a new friend! If you are still stuck, raise your hand and I'll get to you as soon as I can. I'll be surprised if questions don't come up that I haven't thought of yet, so expect this page to update after (or possibly even during) the workshop!

Relax, have fun, and don't worry if your code takes you to someplace different from my examples. That's the idea! Worry less about how you may use this back at school, and instead focus on making things you are happy with. Building on your skill and enjoyment will lead to great stuff back in your classroom.

Let's go!

2. Logging in and Playing Around in Tinkercad

If you don't have a Tinkercad account yet, go to tinkercad.com and click "Join Now." Next, select "I'm and Educator" to create an account that will allow you to make accounts for your students. Use your school email address, and I recommend that you sign up using email, instead of Google, even if your school uses Google Apps. You may want to use Fusion 360 someday, and if you sign up with email, you will be able to use this account for Fusion as well as Tinkercad, and even send Tinkercad projects to Fusion for further work and rendering.

When you are back at school and ready to use Tinkercad with your students, login to your account and go to the Teach button on the top of the screen, then click Go To Classroom. The question mark button in the top right of the screen has some great information on how Tinkercad Classrooms work.

The Workplane and Changing your View

Creating a 3D object on a 2D screen can be tricky. Just like when you are building something in the real world, looking at the object from different angles is vital to putting it together. Before we start assembling anything, let's play around with the view controls a bit and get comfortable with them. No, we won't work through all of the amazing things you can do in Tinkercad (we just don't have time in this workshop)

A quick note about mice and trackpads. Many people find trackpads frustrating when working in 3D space. I am pretty good with them, but I still get frustrated from time to time. In my classroom, I keep a box of mice for kids (and adults) to use if they wish. If you are going to use a trackpad, make sure you have it set up to both right and left click (usually one-finger and two-finger) or you won't be able to do what you need to.

Click "Create a New Design" on your Tinkercad dashboard page, take a look around. You will notice a cube near the top-left corner. This is the Viewcube and by grabbing it and moving your mouse you can spin both the cube and the workplane (and any objects on it). This will be one of the main ways you check out your creations.

Drag a cube onto the workplane. Use the Viewcube to move around and look at the cube from different angles. Click on the cube to select it – you will see small white cubes at each bottom corner and black dots between the corners when selected. Use the Navigation Buttons below the view cube to change your view and discover what they do.

Bring in a "hole colored" cylinder and drag it so that it is 5-10 mm taller than the cube. You want to line it up exactly in the center of the cube, so use the align tool. Drag over both objects so that they are both selected. The align tool is at the top towards the right, it has a vertical line with two rectangles to the right of it. Click it, then click the center dots on both sides of the cube. Presto, the objects are aligned.

Next we will "subtract" the cylinder from the cube. Because we chose the hole colored cylinder, if we group it with the cube it will basically carve its shape out of the cube. Drag over both objects to select them again and you will be able to click the Group button at the top, it looks like a square and circle merging into each other.

This process of selecting shapes, moving and resizing them, and grouping them to merge and subtract, is the basic process you can repeat to make almost anything you can think of. Next we will repeat this process in Codeblocks to get a handle on how it works.

3. Coding 2D Projects in Codeblocks

Let's start playing with codeblocks. We are going to start by coding the same thing that we just created manually in Tinkercad. Just as we did before, we will place a cube, rotate around and check it out, and then add a hole-colored cylinder, group them, and make them green.

A few differences you may have noted is that we didn't have to mess around with aligning the objects, they just ended up centered together. Also, notice that the grouped object isn't sitting on the Workplain, it is half under and half above it. This is because of the different way Codeblocks handles positioning objects. If you have done any coding with graphics before, you will pick up what is happening. The center of the workplane is the origin of an x / y / z space, and each object you create is initially centered on this point. The object is 20mm tall, so in order to sit it on the Workplain we need to move it up on the z axis 10mm. Add a move block to the bottom of your code to do this and see what happens.

Code a Pattern

Ok, let's make something fun! Start a new Codeblocks project by clicking the word "Codeblocks" next to the Tinkercad logo in the top left corner. Add the blocks in the image below – I'll start using comments to explain what each block does as we go.

Run the code and see what it makes. At first glance the block you used doesn't seem like it would make what it made, right? A "tube" made a square? This is a trick in Codeblocks that isn't obvious right away… Remember when we set the number of sides as high as we could earlier when making the cylinder? Tinkercad (and thus codeblocks) makes all of its round objects as polygons with lots of sides – the more sizes the smoother it seems. Actually, all computers do this with circles, Tinkercad just makes it more obvious and controllable. So to make a square (or pentagon, or hexagon…) without the middle filled in (like a cube would be) just make a tube and set the number of sides to 4 (or 5, or 6…). The same thing will happen when you make a torus, except the sides will be rounded instead of straight-edged.

In our code we named our object "box," and because we made it as an object we can make as many duplicates as we like. We are going to create something with a powerful yet simple technique widely used in "Logo-like" programming.
We are going to create a loop that will create multiple copies of the box, placing them in different locations and at different angles each time.

Begin the "Count with" loop that will create your final object.
The first two blocks in the loop make a copy of the box object and move it a bit.
Rotate each duplicate box 45*i degrees around the origin.
Group everything together and delete the original object.

If you copied my code exactly, you should end up with the object to the right. Just copying code isn't very fun though, you need to start messing around a bit! Look at the code and start changing things:

  • colors
  • number of sides and thickness of the "box" object
  • repeats in the loop
  • the distance you move the object
  • degrees rotated
  • ???????

With a little tinkering of the code, you can easily make new, interesting patterns like the ones below.

Detour: Let's Share!

  • Click on the Tinkercad logo in the top left corner of the window.
  • From the list of your project that appears, click the gear icon (the settings) on the project you want to share.
  • Choose Properties
  • Set Privacy to Public and click save changes
  • Re-open your project and copy the URL – you can share this URL with anyone you want!
  • To share with the participants in this workshop, open the Padlet link above, choose the correct column, and share the link.
  • Check out the rest of the participant's designs, look at how they coded them, and like the ones that you think are great!

Detour 2: Coding Something Random

Now that we have some basics of simple 2D design down, let's see what we can make using the random math function, and learn a bit more about some of the coding tools in Codeblocks. Create a new Codeblocks project and add the following code. It will name the object we are creating, and declare two variables that we will need to randomly place the shapes we make.

Next, we will create a Repeat loop to make and move 30 random shapes. You can increase or decrease this (or any other number) when you have the program running, but start small to begin with so it doesn't take too long to run the program while testing. In the loop we will:

  • Make a shape with a random size and number of sides.
  • Choose a random x and y distance to move the shape from the last shape, and add these distances to the variables you created above to determine the new shape's location.
  • Move the shape and repeat.

Once your code works, start to mess with it! Change different numbers to see how it changes the result. Just like any experiment, it is usually a good idea to only change one variable at a time so if it does something great (or not so great) you will know what caused it.

Let's try another, totally different one. Try the code below, and once it works mess with it and make it better!

4. Adding the 3rd Dimension!

Enough with the flat stuff, we have 3D Printers, so lets make something in 3D! The simplicity of getting started with this may seem a bit anticlimactic, but don't worry – you can make things as complex as you want.

Basically, you just need to start moving things on the Z axis, and rotating things on the X and Y axis to start making interesting 3d objects. For example, below is the first version of the Squares program we created in detail above, with just the following changes:

Basically, you just need to start moving things on the Z axis, and rotating things on the X and Y axis to start making interesting 3d objects. For example, below is the first version of the Squares program we created in detail above, with one change: rotating on x instead of z axis.

Here is a 2D project like the ones we created earlier, with only one extra line of code rotating it on the x axis. Try it and make it better.

5. CAD for Engineering 101 – Designing Objects that Work with Real World Objects

I have two Instructables that are already set up to walk teachers through teaching students how to do this, so I'm going to direct you there! Please click the links below, they should open in a new tab so you can come back to this page when you are done.

The first instructable shows you how to use Tinkercad to design a wall holder for your remote control – not any remote control but your specific one. It is an activity I use with my students to teach them how to design around real-world objects to ensure that the object fits into their design. Check out the Instructable here.

6. Fabrication Tips

Resources and Next Steps

So we have scratched the surface, but there is much more left to do! Here are a few online resources – I'm sure a quick search will find you even more. I hope you and your students play and have fun!

  • A getting started tutorial on Instructables: https://www.instructables.com/id/Hour-of-Code-Make-Patterns-With-Code-and-CAD-in-Ti/
  • A great tutorial by Rob Morrill: https://ultimaker.com/learn/code-your-3d-designs-with-tinkercads-new-codeblocks-app

Ho to Use Tinkercad Codeblocks to Create a 30 Design

Source: https://krisswanson.blog/fetc-2020-coding-math-art-and-engineering-with-tinkercad-codeblocks/

0 Response to "Ho to Use Tinkercad Codeblocks to Create a 30 Design"

Mag-post ng isang Komento

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel