OpenSCADCookbook

= Model Design for Re-Use =

This chapter's purpose is designed to get you thinking in terms of model re-use.

Positive and Negative Space
Your code-fu may be strong, but even the simplest of models may be less than manifold. Here are some tricks to help force the issue.

Keep 'em Separated

 * Design your object body parts separate from your object holes

Add Glue Objects to Faces Intended to Bind

 * Design-in simple cube, cylinder and/or sphere geometry at the interface where two parallel object surfaces are intended to join. Helps accomodate floating point errors.

Extend Holes Beyond the Edge

 * Design-in extensions to the holes to fully cut thru the positive space boundary. Helps accomodate floating point errors.

Adding a Bevel to a Cylinder

 * Simple example to illustrate masking operations.

Encapsulating Operations with module/child Constructs

 * While OpenSCAD doesn't allow for the direct assignment of objects to variables for repetitive applications, in certain cases operations can be wrapped in module declarations and the child operator used for multiple application.

Creating Shells - 2D

 * Introduction to the concept for 2D outlines of areas. Creating the second, inner wall.

Creating Shells - 3D

 * Embrace and extend the 2D example.

Using Projections for 2D Slicing

 * Useful for generating 2D slices (like MRI slices) and for combining with linear and rotational extrude operations for quantizing 3D models in an algorithmic fashion.

Array Reuse With File Include and Use Statements

 * Define point arrays in separate files for include and reuse
 * Create functions to access full array of points and size


 * Use violin example.

Interpolated Lookup

 * Quantize, re-index and/or interpolate intermediate points with lookup.

Troubleshooting Polyhedra

 * It's tricky coding these up so they work.

Hierarchical Instantiation
Designing a static hierarchical object is easy. Parametrizing the object hierarchy is a bit trickier.

Basic Humanoid Example
= Model Design for 3D Fabrication =

Things to consider when designing for quirks in your chosen 2D, 2.5D and 3D fabrication process.

Parametric Tolerances

 * Designing for interlock and separation.

Design Simple Unit Test Print Structures

 * Think up the simplest object you can print to measure the limits of your fabrication process.
 * Laser kerf versus thermal expansion.

Pegs

 * 3D printed peg-type structures may grow or shrink in diameter by the deposited material wall (path) thickness.
 * Is often compensated for in the slicing software and/or printer calibration. More of an issue with low-end printers or two-stage manufacturing processes like bronze-infused stainless steel.
 * Circular pegs are only as precise as the line segments that define them.

Holes

 * 3D printed holes may shrink in diameter by up to the deposited material wall (path) thickness.
 * Is often compensated for in the slicing software and/or printer calibration. More of an issue with low-end printers or two-stage manufacturing processes like bronze-infused stainless steel.
 * Circular holes are only as precise as the line segments that define them.
 * See Polygonal hole test by nophead.
 * Laser cut holes grow in diameter by the laser beam's width.
 * Most laser cutters don't know anything about inner vs outer points of enclosed areas

Just Say No to Bell Bottoms

 * Bottom layer edges sometimes flair out in 3D printed designs
 * Design in a bevel around the perimeter to compensate.
 * Is often compensated for in the slicing software and/or printer calibration. More of an issue with low-end FDM printers when printing without a raft or other sacrificial material.

Magnetic Perimeters

 * Close object surfaces tend to merge.
 * All 3D printers have design rules that specify how far apart distinct surfaces must be to remain distinct.
 * Applies to sharp inner angles and longer, narrow-diameter holes.

Orient for Your Strengths

 * Many 3D printing processes are strong in two of three dimensions. In fused deposition modeling (FDM) techniques like those used in MakerBot and RepRap printers, the Z-axis is weakest to shearing forces.
 * Design long, thin parts in the XY plane.
 * Consider orienting irregular shapes at a diagonal X-Z or Y-Z angle for compromise.

Teardrop Tunnels

 * Design in 45-degree maximum overhangs in horizontal holes using tear-drop and truncated tear-drop shapes.

Polar Diamonds

 * Think polar coordinates to create diamond-shaped (squares rotated 45 degrees around their long axis) tunnels and channels at any elevation.

Relativistic Warp
Long threads of hot plastic contract as they cool. For sufficiently long threads, this contraction is some percentage of length. For example, ABS shrinks approximately 0.005m/m, or 0.5% of length. For short segments, these effects can be ignored, but for a 100mm straight run, that amounts to 0.5mm or one filament's diameter.

Bottom Layer Patterns

 * Lattice pattern
 * Notched lines

Rafts Adrift

 * Sometimes help, sometimes hinder.

Cool Assist - PLA

 * PLA is particularly susceptible to curling at sharp corners, such as gear teeth tips. Fan-assisted cooling helps.

Heated Beds and Chambers - ABS

 * Slowing down the rate of cooling for ABS helps promote annealing, reducing mechanical stresses in the plastic as it cools.
 * Sometimes simply cutting down on cross-drafts can cure what ails.

= Reference =

OpenSCAD Source

 * [github:openscad]

OpenSCAD Documentation

 * [OpenSCAD User Manual]