Programming with OpenSCAD: A Beginner's Guide to Coding 3D-Printable Objects

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Programming with OpenSCAD is a STEM-focused, learn-to-code book for beginners that introduces core computational thinking concepts through the design of 3D-printable objects. Develop coding skills as you build increasingly complex 3D models and print them into fun games, puzzles, and more. OpenSCAD is freely available open source software that enables nondesigners to easily create 3D designs using a text-based programming language. It’s a great language for beginners because the instant 3D visualization gives you immediate feedback on the results of your code. This book channels OpenSCAD’s visual benefits and user-friendliness into a STEAM-focused, project-based tutorial that teaches the basics of coding, 3D printing, and computational thinking while you develop your spatial reasoning by creating 3D designs with OpenSCAD. Presuming no prior experience with either programming or 3D design, each chapter builds a scaffolded understanding of core concepts. You’ll start by defining, drawing and displaying geometric primitives with text-based code, then expand your creative toolbox with transformation operations – like rotating, reflecting, scaling, and combining shapes. As the projects become more sophisticated, so will your programming skills; you’ll use loops for replicating objects, if statements for differentiating your designs, and parameterized, self-contained modules to divide longer scripts into separate files. Along the way, you'll learn 3D printing tips so that you can produce physical mementos of your progress and get physical feedback that lets you correct mistakes in real time. In addition, the book provides hands-on and accessible design exercises at the end of each chapter so that you can practice applying new concepts immediately after they are introduced. You’ll learn: • Programming basics like working with variables, loops, conditional statements, and parameterized modules • Transformation operations, such as rotate, reflect, and scale, to create complex shapes • Extrusion techniques for turning 2D shapes into elaborate 3D designs • Computational-thinking concepts, including decomposition, abstraction, and pattern recognition • OpenSCAD’s Boolean, Minkowski and hull operations for combining multiple 3D shapes into one • 3D design fundamentals, like navigating the xyz-axis, orthogonal vs. perspective views, and constructive solid geometry • Organizing bigger designs into separate files to make code more readable and collaborative Accessibly written for a wide audience (advanced middle schoolers, high school students, college students, artists, makers and lifelong-learners alike), this is the perfect guide to becoming proficient at programming in general and 3D modeling in particular.

Author(s): Justin Gohde, Marius Kintel
Edition: 1
Publisher: No Starch Press
Year: 2021

Language: English
Commentary: Vector PDF
Pages: 206
City: San Francisco, CA
Tags: Programming; 3D Printing; Drawings; Do-It-Yourself; Scripting; OpenSCAD

About the Authors
Contents in Detail
Acknowledgments
Introduction
What Is OpenSCAD?
Who This Book Is For
Why Learn to Code with OpenSCAD?
3D Printing and OpenSCAD
What’s in This Book
Terminology and Conventions Used in This Book
A Brief Introduction to 3D Design with OpenSCAD
Understanding 3D Points
Using the OpenSCAD 3D-View Toolbar
Final Tips for Getting the Most Out of This Book
Chapter 1: 3D Drawing with OpenSCAD
Why Use OpenSCAD?
Getting Started with OpenSCAD
Drawing Basic 3D Shapes
Drawing Cuboids with cube
Drawing Spheres with sphere
Drawing Cylinders and Cones with cylinder
Importing 3D Models with import
Modifying Basic Shapes
Moving Shapes
Smoothing Curves with $fn
Combining 3D Shapes with Boolean Operations
Subtracting Shapes with difference
Carving Out Overlapping Shapes with intersection
Grouping Shapes with union
Getting Ready for 3D Printing
Summary
Calibration Pyramid
Smiley-Face Pendant
Hole-and-Pins Test
Chapter 2: More Ways to Transform Shapes
OpenSCAD Shape Transformations
Rotating Shapes with rotate
Reflecting Shapes with mirror
Scaling Shapes with resize
More Ways to Combine 3D Shapes
Combining Shapes with hull
Combining Shapes with minkowski
Combining Transformations
Summary
Game Die
Desktop Organizer
Chapter 3: 2D Shapes
Drawing Basic 2D Shapes
Drawing Circles with circle
Drawing Rectangles with square
Drawing Polygons with polygon
Drawing Words with text
Applying Transformation and Boolean Operations on 2D Shapes
Extruding Shapes Vertically with linear_extrude
Extruding Shapes Along a Circle with rotate_extrude
Growing and Shrinking a Shape with offset
Importing 2D Shapes with import
Summary
Storytelling Dice
Project Box for Storytelling Dice
Trophy
Chapter 4: Using Loops and Variables
Leaving Notes with Comments
Writing Single-Line Comments with //
Writing Multiline Comments with /* */
Repeating Code with a for Loop
Debugging for Loops with echo
Using Variables and Arithmetic
Naming Variables
Applying Mathematical Operations on Variables
Using Math and Variables Inside for Loops
Using Arithmetic to Create Unique Patterns
Using Nested Loops to Draw 2D and 3D Grids
Generating the Windows in a Skyscraper with Nested Loops
Triple Nesting to Create a 3D Grid of Shapes
Summary
Detail Test
Towers of Hanoi Puzzle
Tic-Tac-Toe Game
Chapter 5: Modules
Simplifying Code with Modules
Splitting Your Design into Multiple Files
Adding Parameters to Your Modules
Building a LEGO Brick
Sharing and Collaborating
Summary
Skyscraper
LEGO Library
Chapter 6: Dynamic Designs with if Statements
Using if Statements
Defining Complex Conditions
Choosing Boolean Operators
Using Logical Operators to Combine Boolean Expressions
Following an Expanded Order of Operations
Making Two-Way Choices with if…else Statements
Using Extended if Statements
Using Nested if Statements
Useful Applications of if Statements
Setting Up a Design Mode and Print Mode
Using Random Numbers as a Design Element
Summary
Random Forest
Clock
City of Random Skyscrapers
Chapter 7: Designing Big Projects
The Design Cycle
Leaning Tower of Pisa Model
Step 1: Investigate—Define Multiple Views
Step 2: Plan—Apply Computational Thinking
Step 3: Create—Use a Walking Skeleton Approach
Step 4: Evaluate—Decide Which Design Process Steps to Repeat
Walking Skeleton: Building the Leaning Tower of Pisa
Iteration 1: Connecting the Tower’s Basic Building Blocks
Iteration 2: Finding Repetition in the Middle Section
Iteration 3: Adding More Details to the Middle Section
Iteration 4: Adding Details to the Top Section
Iteration 5: Adding Details to the Bottom Section
Final Evaluation of the Design Cycle
Design Organization Overview
Summary
Afterword
Learn More About OpenSCAD
The Open Source Ethos
Motivation and Ecosystem
Online Citizenship
OpenSCAD and the Maker Movement
Making and Creative Problem-Solving
2D Fabrication
Physical Computing
Makerspaces
Final Ideas for More Practice
Customizable Measuring Spoons
Customizable Vacuum Tool
Customizable Flowerpots
Drawer Box
Lab Clamps
Chess Set
Pegboard Wizard
Appendix A: OpenSCAD Language Reference
Syntax
Operators
2D Shapes
3D Shapes
Boolean Operations
Shape Transformations
Loops, Decisions, and List Comprehensions
Other Shape Operations
Modifier Characters
Special Variables
Mathematical Functions
Other Functions
Appendix B: OpenSCAD Visual Reference
3D Primitives
2D Shapes
Combining Shapes
Transformations
Loops
Index