SCAD+
Verts: 0 · Faces: 0 · Time: 0ms

SCAD Language Reference

3D Primitives

FunctionParametersDescription
cubesize, center, anchor, fillet, chamfer, edges, $fnBox. size: number or [x,y,z]. Fillet > 0 convex, < 0 concave.
spherer, d, anchor, $fnIcosphere. r = radius, d = diameter.
cylinderh, r, d, r1, r2, d1, d2, center, anchor, fillet, fillet_top, fillet_bot, chamfer, chamfer_top, chamfer_bot, $fnCylinder or cone. r1/r2 for conical.
torusr1, r2, angle, $fnTorus. r1 = major, r2 = minor. angle for partial sweep.
ellipsoidr, rx, ry, rz, $fnEllipsoid. r: scalar or [rx,ry,rz].
pipeh, r, t, r_inner, center, anchor, fillet, chamfer, $fnHollow cylinder. t = wall thickness.
wedgesize, center, anchorTriangular prism. size: scalar or [w,d,h].
capsuleh, r, center, anchor, $fnPill shape. Sphere if h ≤ 2r.
rounded_cubesize, r, center, anchor, $fnRounded box via hull of 8 spheres.
polyhedronpoints, facesRaw mesh from vertices and face indices.
threadd, pitch, length, starts, profile_angle, center, anchor, $fnHelical screw thread.
springr, r_wire, pitch, turns, center, anchor, $fnHelical coil wire.

2D Primitives

Use inside linear_extrude() or rotate_extrude(), or as thin top-level 3D shapes.

FunctionParametersDescription
circler, d, $fnCircle. r = radius, d = diameter.
squaresize, center, $fnRectangle. size: scalar or [w,h].
polygonpoints, paths, $fn2D polygon from point array. paths for holes.
regular_polygonr, n, $fnRegular n-gon. n = sides (default 6).
hexagonrAlias for regular_polygon(r, n=6).
slotw, h, center, $fnStadium / obround shape.
starpoints, r_outer, r_innerStar polygon. points = number of points.

Extrusions

FunctionParametersDescription
linear_extrudeheight, twist, slices, scale, centerExtrude 2D shape along Z. scale: scalar or [sx,sy].
rotate_extrudeangle, $fnRevolve 2D profile around Z-axis.

Transforms

FunctionParametersDescription
translate[x, y, z]Move children by offset vector.
rotate[x, y, z]Rotate children (degrees).
scale[sx, sy, sz]Scale children. Scalar for uniform.
colorc, alphaApply color (hex or CSS name) and opacity.

Boolean Operations

FunctionParametersDescription
unionchildrenCombine all shapes.
differencechildrenFirst child minus the rest.
intersectionchildrenKeep only overlapping volume.
hullchildrenConvex hull of children.
minkowskichildrenMinkowski sum of children.

Control Flow

SyntaxExampleDescription
forfor (i = [0:5]) { ... }Loop. Supports [start:end], [start:step:end], arrays.
if / elseif (x > 0) { ... } else { ... }Conditional geometry.
modulemodule name(p=1) { ... }Define reusable module.
$fn$fn = 64;Global resolution (circle segments).
##cube(10);Debug: highlight in translucent pink.

Layout Modules

Place inside a shape's { } block to position children relative to the parent shape.

FunctionParametersDescription
positionanchor, pad, extend, axis, modePlace child center at parent's anchor point. No rotation.
alignface, alignment, inset, pad, extend, axis, modeFlush child face to parent face with auto-anchoring. Standalone mode moves anchor to origin.
attachparent_anchor, child_anchor, overlap, spin, align, pad, extend, axis, modeRotate child UP to parent face normal, position child_anchor at parent_anchor. BOSL2-style.
framesizeInvisible phantom bounding box for layout. Shown as dashed wireframe.
groupchildrenExplicit union. Layout children use combined bounding box.

Layout Modes

ModeDescription
"add"Default. Union child with parent.
"cut"Subtract child from parent.
"intersect"Keep only overlap of child and parent.

Hardware Components

FunctionParametersDescription
boltsize, length, d, head_h, head_d, pitch, thread_length, chamfer, standard, center, $fnISO metric hex bolt. size: "M1".."M30". standard: "din" or "iso". Origin at head bottom.
nutsize, h, d, s, thread, pitch, chamfer, standard, center, $fnISO metric hex nut. thread: boolean for threaded bore.
enclosuresize, wall, r, fillet_top, fillet_bottom, chamfer_top, chamfer_bottom, lid_h, lip_h, lip_gap, mount, screw_size, screw_d, screw_inset, boss_r, hole_depth, nut_pocket, part, center, $fnParametric box with lid. size: [w,d,h]. mount: "none"/"screw"/"bolt". part: "assembly"/"body"/"lid".
shellthickness, openHollows out child shapes. thickness: wall thickness (pos 0, default 2). open: anchor face to remove (e.g. TOP). Uses scale-from-center.

Gears & Mechanical

FunctionParametersDescription
spur_gearteeth, mod, pressure_angle, width, bore, backlash, center, $fnInvolute spur gear.
helical_gearteeth, mod, pressure_angle, width, helix_angle, bore, backlash, center, $fnSpur gear with helical twist.
herringbone_gearteeth, mod, pressure_angle, width, helix_angle, bore, backlash, center, $fnV-pattern double helical gear.
rackteeth, mod, pressure_angle, width, height, backlash, center, $fnLinear gear rack.
bevel_gearteeth, mod, pressure_angle, width, cone_angle, bore, backlash, center, $fnBevel gear for angled shafts.
wormstarts, mod, pressure_angle, length, d, r, bore, center, $fnHelical worm for worm-gear drives.

Structural Profiles

Thin-walled extrusions. All share: w (width), h (height), t (thickness), l (length), fillet, chamfer, center, $fn.

FunctionExtra ParametersDescription
l_profilefillet_outside, chamfer_outsideL-shaped cross-section.
u_profilefillet_outside, chamfer_outsideU-shaped (channel).
o_profilefillet_outside, chamfer_outsideRectangular tube.
t_profiletwT-shaped. tw = web thickness.
i_profiletwI-beam. tw = web thickness.

Anchor Constants

Combinable with + for edges and corners (e.g. TOP + RIGHT + FRONT).

ConstantValueDescription
CENTER[0, 0, 0]Bounding box center
TOP[0, 0, 1]Z+ face
BOTTOM[0, 0, -1]Z- face
RIGHT[1, 0, 0]X+ face
LEFT[-1, 0, 0]X- face
BACK[0, 1, 0]Y+ face
FRONT[0, -1, 0]Y- face

Axis Constants

ConstantValueUsage
X[1, 0, 0]X axis only
Y[0, 1, 0]Y axis only
Z[0, 0, 1]Z axis only
XY[1, 1, 0]X and Y axes
XZ[1, 0, 1]X and Z axes
YZ[0, 1, 1]Y and Z axes

Math Functions

CategoryFunctions
Trigonometry (degrees)sin(x), cos(x), tan(x)
Roundingabs(x), ceil(x), floor(x), round(x)
Exponentssqrt(x), pow(x, y)
Logarithmsln(x), log(x)
Comparisonmin(a, b, ...), max(a, b, ...)
ConstantsPI

View Navigation

KeyAction
Num 1Front view
Ctrl + Num 1Back view
Num 3Right view
Ctrl + Num 3Left view
Num 7Top view
Ctrl + Num 7Bottom view
Num 5Toggle Ortho / Perspective

Transform

KeyAction
TTranslate mode
RRotate mode (Shift = 45° snap)
SScale mode

Selection & View

KeyAction
FFit view to selection
NFit view with normal
EscDeselect all
DeleteDelete selected object

Dimension Dragging

KeyAction
XConstrain to X-axis
YConstrain to Y-axis
ZConstrain to Z-axis