Learn to Design With Code Using Tinkercad Codeblocks: a Quick-Start Guide

by tinkercad-support in Circuits > Software

64969 Views, 109 Favorites, 0 Comments

Learn to Design With Code Using Tinkercad Codeblocks: a Quick-Start Guide

CodeblocksAnglerUpdateSM.gif

Tinkercad's new Codeblocks computational design workspace is the simplest place to make 3D models using draggable blocks of code.

Learn basic design and coding principles in an easy-to-learn workspace using Scratchblocks 3.0 as seen in MIT's Scratch application.

Let's get started!

Sign in to Tinkercad

Screen Shot 2022-09-08 at 10.54.32 AM.png

Instructions

  1. Go to Tinkercad.com
  2. Sign in to your account (or create one if this your first visit)
  3. Once you are signed in, you will land in the User Dashboard.
  4. If you have never worked with 3D modeling or in Tinkercad before, it might be worth checking out our Learning Center to learn the basics.
  5. If you are excited to get coding, scroll down to the bottom of the page and click the "Create your first Codeblocks design" button. (You can also create new designs using the blue "+ New" button on the top right of the User Dashboard.)
  6. Continue to the next steps to see how it works!

Viewing the Workspace

CodeblocksWorkspaceDiagram.png

When you drop into the Codeblocks workspace, you can see it is very similar to Tinkercad's 3D workspace, but broken up into several sections:

  • Navigation (Nav) Bar - Macro controls that are used across all Tinkercad workspaces.
  • Tool Bar - View, Name, Edit and Export your Design.
  • Blocks Panel - Scroll to view a variety of Codeblock options.
  • Blocks Editor - Stack your Codeblocks here to define and refine your Design.
  • 3D Viewer - See the results of what you built in the Block Editor.

Now that we know the layout, let's begin building!

Codeblocks Activities & Starter Lessons

cblocksredo.gif

The Tinkercad Codeblocks workspace now has its own suite of interactive starter activities to help new users learn the moves. Check out our Learning Center to see the Codeblocks Activities and Starter Designs we have available.

Otherwise, you'll find these activities by clicking the word “Codeblocks” in the top left corner (as shown below). From this same window you can also find our Codeblocks Quick Start guide , as well as view and pick apart a handful of great starter designs.

The three new interactive learning activities help beginners take their first steps in computational design and modeling. Activities include:

  • Intro to Shapes- covers the basics of manipulating the size and color of Shapes and employs core concepts of 3 dimensional space (WxLxH). 
  • Moving Shapes- covers the basics of navigating Shapes through 3 dimensional space, assembling Shapes to build simple things and introducing 3D technical concepts like workspace origin, XYZ axes, plotting with Cartesian coordinates, positive/negative direction, perspective vs. orthogonal views and quadrants.
  • Rotating Shapes- challenges users to explore single and multi-axis rotation reinforces earlier 3D technical concepts like workspace origin, XYZ axes, plotting with Cartesian coordinates, positive/negative direction, as well as rotational increments.


Designing With Code- the Process

CodingProcessDiagram.jpg

Design is a process of making creative decisions to create something and then refining those decisions until you, as the creator, determines the project is complete.

The same thing is true for coding, it is a process where you make decisions, using commands, until you have achieved the outcome that you are looking for.

In Codeblocks, there is a repeating rhythm to this process. Let's take a look at the steps:

  1. Select - You start by Selecting a Codeblock, preferably a Shape Block, like the Box from the Block Panel on the far left side.
  2. Stack - Click and drag it from the Block Panel into the middle of the Block Workspace, as shown above. This is where you Stack the blocks to create a script.
  3. Run - Once you have placed the Shape, you look to the upper right hand corner for the Run Button and click it.
  4. Review - Below the Run button is the 3D Viewer where you view your work or Review any changes you have made to your design. In the 3D viewer, you should see a 3D version of the Shape that you selected in Step
  5. Adjust - From here, you would go back to the Block workspace and Adjust your Design by dragging in another block or making changes to the Shape that you have already selected.

As mentioned, you will continue this process - Select, Stack, Run, Review, Adjust - until your design is finished.

Now that you have a feel for the process, let's take a closer look at the most common features of the Codeblocks workspace.

Stack It!

CodeblocksStackItCut.gif

To design things in Codeblocks, you snap blocks of code together to form a Stack of sequential commands or actions. These actions control the Shapes and the result is a 3D Design that you can view in the 3D Viewer.

Let's start by dragging in the 'Box' Shape block.

Instructions

  1. Locate the Block Panel, on the left side of the workspace. This is a list of all the blocks available.

  2. Click and hold on the red Box block and drag it from the Block panel into the middle area, called the Block Editor.

    (Note: To work properly, there must always be at least one Shape in your stack.)

  3. Click Next to learn how to Run the code and see the Box in the 3D Viewer.

Run It!

CodeblocksRunItCut.gif

Since we are using code to create our design, we need to Run that code see your result in the 3D Viewer. This is an important process and one that you will repeat over-and-over as you update your design.

Instructions

  1. Locate the Run button in the top right corner of the Workspace. This area is called the ToolBar.
  2. Press the Run button

  3. Watch your Box Shape load in the 3D Viewer
  4. Click Run again to see your Shape reload. Now you are coding!

    (Note: See how your Box has loaded in the very center of the grid and is 1/2 above and 1/2 below the Workplane? This is normal and slightly different than Tinkercad's regular 3D workspace, where Shapes load on top of the Workplane.)

  5. Continue to the next step to see how to control the view of your Shape in the 3D Viewer.

View It!

CodeblocksViewItCut.gif

Now you have seen your 3D Shape load in the 3D Viewer, let's look at how to view it from a variety of angles.

There are 2 main ways to control the camera in the 3D Viewer-

Instructions

  1. Move using the in-screen controls-
  2. The ViewCube is like a mini controller for the screen. It has labels of the various view angles (front, top, etc.) that match the workspace. 'Grab' it by clicking your mouse on it and dragging to rotate.
  3. For quick view changes, you can click the various labels or fields. Hover your cursor or finger over top of the ViewCube and you can see the fields highlight. Click any of the fields to see your model from that angle.
  4. To Zoom in and out, click the '+' and '-' Zoom buttons
  5. Move using your mouse (or touch gestures). There are 3 different control points-
  6. Orbit- Used to rotate around the model. To Orbit, hold own the Control key, while dragging your mouse anywhere within the Viewer area. For touch controls, drag one finger anywhere outside your design.
  7. Pan- Used to move sideways or up and down to center your model in the Viewer. To Pan, press and hold the 'Shift' and 'Control' key while using the mouse to click and drag anywhere within the View area. For touch control, use two fingers and drag anywhere outside your design.
  8. Zoom- Zoom in and out to view small details. To Zoom, use the scroll wheel on your mouse. For touch, use two fingers to pinch or pull on your trackpad or touch screen.
  9. Continue to the next step and let's make some changes to its Shape.

Shape It!

CodeblocksShapeItCut.gif

Most Shapes have onboard controls that let you modify the Shape to fit your needs.

Instructions

  1. Locate the arrow icon on the right side of the Box Shape block.

  2. Click the arrow to open the drawer. You will see a list of controls with number fields. These numeric controls are called Parameters. They control certain attributes of the Box Shape, like Width (W), Length (L) and Height (H). Let's change the Width.

  3. Click into the white Field area next to the W (for Width). This will highlight the 20.

  4. Type 40 in the field.
  5. Now press Run and review your Shape. Does your Box look more rectangular now? That's good. If not, maybe check the field to be sure your number was input correctly.
  6. Experiment- Now that you've seen how to modify your Shape, feel free to try some of the other controls to see how they effect the Shape!
  7. When you are ready, let's move your shape around the Workspace.

Move It!

CodeblocksMoveItCut.gif

To move Shapes in the workspace, you use the Move block. It works like taking steps along a path starting at the Shape's current location on the grid, which for your Box is 0.

Instructions

  1. Locate the Move block in the Block Panel by scrolling down to the Modify category.

  2. Click and hold on the Move block and drag it into the Block Editor.

  3. Hover the Move block toward the bottom of the Box block and you will see a shadow appear. If you let go, the Move block will snap onto the Box block.

    Important tip: All non-Shape blocks require a Shape to do their action. Many blocks take action on only the nearest Shape above them. If there is only one Shape in the workspace, attaching the Move block on top of a Shape won't effect an action on that Shape.

  4. Now that the Move block is below the Box block, we can use it to move the Box in the 3D Viewer. Like before, let's click into the 'X' Field where we see a 0 and type 50. This will move the Box far enough that you will see the difference.
  5. Now, click Run and notice how far the Box moves. It has moved 50 mm along the X axis.

    (Note: You can see which direction the X axis runs by looking at the Red line near the center of the Workspace. You can also see the direction of the Y axis in Green and the Z axis, that runs up and down, in Blue.)

  6. Experiment- What if you want the Box to move along the same path (axis), but in the opposite direction? Use math! Like a number graph, if we started at 0 and wanted to move to 50. We move by 1 until we get to 50. The opposite direction on the graph would start at 0 and move using negative numbers, so 50 steps in the opposite direction is -50. Enter -50 in the 'X' field and press Run. Did it Move in the opposite direction?
  7. Lastly, play around with the numbers in the other axes (Y and Z).
  8. When you are ready to move on, click Next and we'll do some spinning.

Rotate It!

CodeblocksRotateItCut.gif

You can attach the Rotate block to your stack to add a rotation movement.

At this point, your stack should have a Box block with a Move block snapped to it.

Instructions

  1. Locate the Rotate block in the Block Panel. You can also find it in the Modify category.

  2. Click and hold to drag the Rotate block into the Block Editor and hover at the bottom of the stack until you see the shadow. This lets you know that it is close enough to snap onto the stack. Release your block.

  3. Click the 'Axis' field to see a dropdown of the 3 axes we learned in Move it!. Select an axis and click return.

  4. Click into the 'Degrees' field. Change it from 90 to 45.
  5. Now press the Run button to see your Box rotate.
  6. Experiment- Now that you see how it works, play around with the fields to see how the controls work. Also, try dragging the Rotate block to a different area of the script, like just below the Box block. Notice how the sequence of actions has changed.
  7. Now try to drag another Rotate block into the Stack to add multiple Rotation actions.
  8. Continue to the next step.

Color It!

CodeblocksColorItCut.gif

Color adds a new dimension to the look of your models and its easy to change.

Instructions

  1. Find the Shape block for the Shape you'd like to change the color of.
  2. Click the colored circle on the Shape block. This will open the Color Menu.

  3. Click on the color swatch you would like.
  4. Click anywhere outside the Color Menu to close it.
  5. You've learned enough of the basics, now we can bring them all together to make a model.

Aligning Shapes to Make Something

CodeblocksAlignItCut.gif

Since every Shape loads at the origin point at the center of the workspace, it's pretty easy to align Shapes, by stacking them on top of one another. Let's make a quick rocket to show how.

If you have any blocks in your Block Editor, drag them all to the Trash icon in the bottom right corner.

Instructions

  1. Drag three Shapes into the Block Editor - a Cone, a Cylinder, and a Star (the Yellow one). Press Run to review your work.

  2. We want all of these Shapes to stack from top-to-bottom, but let's adjust the size of them first. Click the Arrow to open the control drawer for the Cylinder and increase the 'H' (Height) field from 20 to 40.

  3. Click the Arrow to open the drawer of the Star and set the 'Radius' field to 17. Press Run to review your work.

  4. Notice how all your Shapes are floating in the center? Let's move them to assemble our Rocket. Drag in a Move block for the Cone and insert it into the Stack just below the Cone Block. Now repeat for the Cylinder and the Star.

  5. Let's move the Cylinder so it sits on top of the Workplane. We use the 'Z' axis to move up and down. Since the Cylinder is half above the Workplane and half above, we should be able to calculate half the total height to move it to the top of the Workplane. In the 'Z' field on the Cylinder's Move block, input 20. Run to check your work.

  6. Is your Cylinder sitting on top of the Workplane? If so, let's move the Cone Shape to the top of the Cylinder. Try to calculate how far to move it. Enter it into the Cone's Move block and hit Run to check your work. Its okay if it takes a couple tries to get it right.

  7. Once you have the Cone Shape sitting on top of the Cylinder, let's move the Star Shape up to sit on the Workplane. Calculate and input the number into the 'Z' field of the Move block attached to the Star Shape and press 'Run' to check your work.

  8. How does your Rocket look? Maybe your Star Shape looks a bit out of alignment? Sometimes, to align Shape with an odd number of sides, its best to make it an even number. Let's reset the number of sides on the Star to 6 to make sure all the parts are aligned correctly.

  9. Does your design look like a Rocket? Congratulations! By using a combination of Move and Rotate blocks, you can assemble Shapes into all kinds of amazing objects.
  10. Experiment- Now that you have a finished Design, what would you do to change it? Can you see areas to play with the Shape of the pieces? How does changing the color change the Design? Share your work with a classmate or friend.
  11. Before we move on to another Design, let's save this one and open a New Design.

Save It!

Screen Shot 2019-02-21 at 2.35.40 PM.png

This step is sort of a trick since Tinkercad automatically Saves your Designs while you work, but its important to know when a Design might be finished and when to start a new one.

Instructions

  1. To prepare your Design for closing, click the Name field on the top right, in the Toolbar. It probably has some sort of funny placeholder name. Click on the letters to select them.

  2. Type a new name for your Rocket Design and click Return on your keyboard.

  3. Now, click the 'Codeblocks' button to the left of the Name Field. This is how you open the Mini-dashboard.

  4. Click the 'New Design' button in the top right corner. This will Save your last Design in its current state and Open a New and Empty Design.

  5. Now let's see how to combine your Shapes to move and modify portions of your design.

Group It!

CodeblocksGroupItCut.gif

Grouping is one of the most important actions in Tinkercad because it allows you combine parts of your design for easy movement or modification. This will also help prepare them for 3d printing.

Instructions

  1. Drag a Box and Cylinder into the Block Editor.
  2. Attach the Cylinder to the Box block.

  3. Click the arrow to open the Control drawer. Click into the Radius field and change the number to 6. Click into the 'H' (Height) field and change it 30.

  4. Drag a Create Group block into the Block Editor and attach it to the bottom of the Stack.

  5. Drag a Move block and attach it to the bottom of your Stack below the Create Group block and change the X and Y fields to '10'. Click the 'Run' button to review your model. The grouped parts should now move as a single part.

  6. Exploration- Insert a Move or Rotate block above the Create Group block to see what happens to your Design. Try adding a Shape after the Create Group block and try to Move or Rotate it.
  7. Let's see how to cut a Hole in a Shape using the Group block.

Cut a Hole in It!

CodeblocksHoleCut2.gif

A Hole is a Shape that has been changed to cut into another Shape. It is activated when you use a Group block to combine regular Shapes and Holes.

Instructions

  1. Clear your Block Editor by dragging all your blocks into the Trash.

  2. Drag a Box and Cylinder into the Block Editor. Snap the Cylinder to the bottom of the Box block.

  3. On the Box block, click the Arrow to open the Control drawer. Reduce the Height of the Box, by clicking into the 'H' (Height) field. Change the number to 10.

  4. On the Cylinder block, next to the Color field, is the Hole field. When you click this, it deselects the Color field turning the Shape into a Hole.

  5. Click 'Run' to view your Shapes. Notice that your Box is still a Solid color and the Cylinder is now transparent. See where the Box and Cylinder meet? This shows where the Hole will be cut into your Box Shape

  6. Drag a 'Create Group' block into the Block Editor and attach it to the bottom of the Stack. Click 'Run' to update your 3D View. You can see that the 'Create Group' has combined the Shape and Hole, leaving a Cylinder-shaped Hole in the solid Box.

  7. Exploration- What happens when you move the Cylinder around toward the edges of the Box using the Move block? What happens when you Move the Cylinder completely outside the edges of the Box Shape?
  8. Continue to the next step.

Print It!

CodeblocksPrintItCut2.gif

If you have access to a 3D printer, you can export your Design as an .stl file for printing.

Instructions

  1. Find and click the Export button in the Toolbar.

  2. In the menu, click the .STL button (or .OBJ if you are printing to a multi-color printer).

  3. Look in the Downloads folder of your Computer for the name of your Design.
  4. Use your printer software to prepare your file for print.
  5. Load the file to the printer and press Start!
  6. Continue to the next step

Make a GIF Animation!

GIFMaker.gif

It's fun to watch your Codeblocks Designs auto-build as an animation. You can share animations of your Design building using the .GIF creation tool.

Instructions

  1. Find and click the Share button in the Toolbar.

  2. Position Your Design in the 3D Viewer using the same tools (Orbit, Pan and Zoom) that you learned in the 'View it!' section.
  3. Click 'Animated GIF' to start the Design build sequence.

  4. If you want to get fancy, use the 3D Viewer tools to Orbit around your model while it records to feature specific parts of the build sequence.
  5. Once the Design finishes building, the tool assembles the images into a full animation. This may take a couple of minutes if the design is complex. When complete, a .GIF file with your Design's name will be dropped into your Downloads folder.
  6. Once finished, close the window using the Close button and return to the Codeblocks workspace.
  7. View your .GIF by dragging it into a browser tab or email to friends and family.
  8. Continue to the next step.

Make a Part for Reuse!

CodeblocksMakeAPartCut.gif

The PartMaker tool will turn your design into a single, combined part and send it to your Parts Collection in Tinkercad's 3D workspace for adding to other Designs.

Instructions

  1. Finalize your Codeblocks Design.
  2. Find and Click the Export button in the Toolbar.

  3. Click the Part button in the menu.

  4. In the Part publishing dialog, add information about your Part, like Name, Description, and Tags.

  5. Click the 'Save Part' button and the workspace will close and return you to the Codeblocks Workspace.

  6. To leave the Codeblocks Workspace and use your Part in the 3D workspace, click the Tinkercad Icon in the top left corner.

  7. In the User Dashboard, click 'Tinker This' button on an existing Design or click the 'Create New Design' button to open a Design.

  8. Once in the 3D Workspace, look to the Shape Panel on the right side and click the 'Basic Shapes' button.

  9. In the dropdown menu, look down near the bottom and click the 'Part Collection' button.

  10. Your new Part should appear at the top of the Part Collection.

  11. Drag your new Part into the 3D Workspace and start designing!

    (Note: Making and using Parts can save you a lot of time and effort on your design, especially with things that you do over-and-over. What other kind of things would you make and use in the 3D editor?)

  12. Continue to the next step

Now You Know the Basics, Go Design Something!

Bridge2.gif

We've covered the basic functions of the Codeblocks workspace. This should give you the perfect launch point for exploring the rest of the blocks and workspace features.

Happy Coding!