Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Simplifying 3D Printing with OpenSCAD

You're reading from   Simplifying 3D Printing with OpenSCAD Design, build, and test OpenSCAD programs to bring your ideas to life using 3D printers

Arrow left icon
Product type Paperback
Published in Mar 2022
Publisher Packt
ISBN-13 9781801813174
Length 320 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Colin Dow Colin Dow
Author Profile Icon Colin Dow
Colin Dow
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Part 1: Exploring 3D Printing
2. Chapter 1: Getting Started with 3D Printing FREE CHAPTER 3. Chapter 2: What Are Slicer Programs? 4. Chapter 3: Printing Our First Object 5. Part 2: Learning OpenSCAD
6. Chapter 4: Getting Started with OpenSCAD 7. Chapter 5: Using Advanced Operations of OpenSCAD 8. Chapter 6: Exploring Common OpenSCAD Libraries 9. Part 3: Projects
10. Chapter 7: Creating a 3D-Printed Name Badge 11. Chapter 8: Designing and Printing a Laptop Stand 12. Chapter 9: Designing and Printing a Model Rocket 13. Part 4: The Future
14. Chapter 10: The Future of 3D Printing and Design 15. Other Books You May Enjoy

Simplifying our code with modules

As we've seen, OpenSCAD code can start to become quite complex. This not only makes it more difficult to maintain but makes our coding prone to errors. An elegant way to deal with this is to break our code into modules. Although we can put any code we want into a module, it is best practice to keep a module limited to a single function. For example, a good way to break up the Thumbs Up award would be by using code to create the base, code to create the Thumbs Up symbol, and code to create the plaque.

The syntax to create a module in OpenSCAD is the word module, followed by opening and closing parenthesis and open and closing curly braces:

module name_of_module(parameters)
{
     body_of_module
}

As we can see, modules are similar in their syntax to the difference, union, and intersection operations. It is a good idea to name the modules with verbs since they perform actions.

We will start exploring modules...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime