Skip to content
/ BOSL Public
fe60 edited this pageJan 9, 2022· 48 revisions

Library File shapes.scad

Common useful shapes and structured objects. To use, add the following lines to the beginning of your file:

include <BOSL/constants.scad>
use <BOSL/shapes.scad>

Table of Contents

  1. Cuboids

  2. Prismoids

  3. Cylindroids

  4. Spheroids

  5. 3D Printing Shapes

  6. Miscellaneous

  7. Deprecations


1. Cuboids

cuboid()

Description: Creates a cube or cuboid object, with optional chamfering or filleting/rounding.

ArgumentWhat it does
sizeThe size of the cube.
chamferSize of chamfer, inset from sides. Default: No chamferring.
filletRadius of fillet for edge rounding. Default: No filleting.
edgesEdges to chamfer/fillet. Use EDGE constants from constants.scad. Default: EDGES_ALL
trimcornersIf true, rounds or chamfers corners where three chamferred/filleted edges meet. Default: true
p1Align the cuboid's corner at p1, if given. Forces align=V_UP+V_BACK+V_RIGHT.
p2If given with p1, defines the cornerpoints of the cuboid.
alignThe side of the origin to align to. Use V_ constants from constants.scad. Default: V_CENTER
centerIf given, overrides align. A true value sets align=V_CENTER, false sets align=V_UP+V_BACK+V_RIGHT.

Example 1: Simple regular cube.

cuboid(40);

cuboid() Example 1

Example 2: Cube with minimum cornerpoint given.

cuboid(20, p1=[10,0,0]);

cuboid() Example 2

Example 3: Rectangular cube, with given X, Y, and Z sizes.

cuboid([20,40,50]);

cuboid() Example 3

Example 4: Rectangular cube defined by opposing cornerpoints.

cuboid(p1=[0,10,0], p2=[20,30,30]);

cuboid() Example 4

Example 5: Rectangular cube with chamferred edges and corners.

cuboid([30,40,50], chamfer=5);

cuboid() Example 5

Example 6: Rectangular cube with chamferred edges, without trimmed corners.

cuboid([30,40,50], chamfer=5, trimcorners=false);

cuboid() Example 6

Example 7: Rectangular cube with rounded edges and corners.

cuboid([30,40,50], fillet=10);

cuboid() Example 7

Example 8: Rectangular cube with rounded edges, without trimmed corners.

cuboid([30,40,50], fillet=10, trimcorners=false);

cuboid() Example 8

Example 9: Rectangular cube with only some edges chamferred.

cuboid([30,40,50], chamfer=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);

cuboid() Example 9

Example 10: Rectangular cube with only some edges rounded.

cuboid([30,40,50], fillet=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);

cuboid() Example 10


span_cube()

Description: Creates a cube that spans the X, Y, and Z ranges given.

ArgumentWhat it does
xspan[min, max] X axis range.
yspan[min, max] Y axis range.
zspan[min, max] Z axis range.

Example:

span_cube([0,15], [5,10], [0, 10]);

span_cube() Example


leftcube()

Usage:

  • leftcube(size);

Description: Makes a cube that is aligned on the left side of the origin.

ArgumentWhat it does
sizeThe size of the cube to make.

Example:

leftcube([20,30,40]);

leftcube() Example


rightcube()

Usage:

  • rightcube(size);

Description: Makes a cube that is aligned on the right side of the origin.

ArgumentWhat it does
sizeThe size of the cube to make.

Example:

rightcube([20,30,40]);

rightcube() Example


fwdcube()

Usage:

  • fwdcube(size);

Description: Makes a cube that is aligned on the front side of the origin.

ArgumentWhat it does
sizeThe size of the cube to make.

Example:

fwdcube([20,30,40]);

fwdcube() Example


backcube()

Usage:

  • backcube(size);

Description: Makes a cube that is aligned on the front side of the origin.

ArgumentWhat it does
sizeThe size of the cube to make.

Example:

backcube([20,30,40]);

backcube() Example


downcube()

Usage:

  • downcube(size);

Description: Makes a cube that is aligned on the bottom side of the origin.

ArgumentWhat it does
sizeThe size of the cube to make.

Example:

downcube([20,30,40]);

downcube() Example


upcube()

Usage:

  • upcube(size);

Description: Makes a cube that is aligned on the top side of the origin.

ArgumentWhat it does
sizeThe size of the cube to make.

Example:

upcube([20,30,40]);

upcube() Example


2. Prismoids

prismoid()

Usage:

  • prismoid(size1, size2, h, [shift], [orient], [align|center]);

Description: Creates a rectangular prismoid shape.

ArgumentWhat it does
size1[width, length] of the axis-negative end of the prism.
size2[width, length] of the axis-positive end of the prism.
hHeight of the prism.
shift[x, y] amount to shift the center of the top with respect to the center of the bottom.
orientOrientation of the prismoid. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Z.
alignAlignment of the prismoid by the axis-negative (size1) end. Use the V_ constants from constants.scad. Default: ALIGN_POS.
centerIf given, overrides align. A true value sets align=V_CENTER, false sets align=ALIGN_POS.

Example 1: Rectangular Pyramid

prismoid(size1=[40,40], size2=[0,0], h=20);

prismoid() Example 1

Example 2: Prism

prismoid(size1=[40,40], size2=[0,40], h=20);

prismoid() Example 2

Example 3: Truncated Pyramid

prismoid(size1=[35,50], size2=[20,30], h=20);

prismoid() Example 3

Example 4: Wedge

prismoid(size1=[60,35], size2=[30,0], h=30);

prismoid() Example 4

Example 5: Truncated Tetrahedron

prismoid(size1=[10,40], size2=[40,10], h=40);

prismoid() Example 5

Example 6: Inverted Truncated Pyramid

prismoid(size1=[15,5], size2=[30,20], h=20);

prismoid() Example 6

Example 7: Right Prism

prismoid(size1=[30,60], size2=[0,60], shift=[-15,0], h=30);

prismoid() Example 7

Example 8: Shifting/Skewing

prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5]);

prismoid() Example 8


rounded_prismoid()

Description: Creates a rectangular prismoid shape with rounded vertical edges.

ArgumentWhat it does
size1[width, length] of the bottom of the prism.
size2[width, length] of the top of the prism.
hHeight of the prism.
rradius of vertical edge fillets.
r1radius of vertical edge fillets at bottom.
r2radius of vertical edge fillets at top.
shift[x, y] amount to shift the center of the top with respect to the center of the bottom.
orientOrientation of the prismoid. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Z.
alignAlignment of the prismoid by the axis-negative (size1) end. Use the V_ constants from constants.scad. Default: V_UP.
centervertically center the prism. Overrides align.

Example 1: Rounded Pyramid

rounded_prismoid(size1=[40,40], size2=[0,0], h=25, r=5);

rounded_prismoid() Example 1

Example 2: Centered Rounded Pyramid

rounded_prismoid(size1=[40,40], size2=[0,0], h=25, r=5, center=true);

rounded_prismoid() Example 2

Example 3: Disparate Top and Bottom Radii

rounded_prismoid(size1=[40,60], size2=[40,60], h=20, r1=3, r2=10, $fn=24);

rounded_prismoid() Example 3

Example 4: Shifting/Skewing

rounded_prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5], r=5);

rounded_prismoid() Example 4


right_triangle()

Usage:

  • right_triangle(size, [orient], [align|center]);

Description: Creates a 3D right triangular prism.

ArgumentWhat it does
size[width, thickness, height]
orientThe axis to place the hypotenuse along. Only accepts ORIENT_X, ORIENT_Y, or ORIENT_Z from constants.scad. Default: ORIENT_Y.
alignThe side of the origin to align to. Use V_ constants from constants.scad. Default: V_UP+V_BACK+V_RIGHT.
centerIf given, overrides align. A true value sets align=V_CENTER, false sets align=V_UP+V_BACK+V_RIGHT.

Example 1: Centered

right_triangle([60, 10, 40], center=true);

right_triangle() Example 1

Example 2: Non-Centered

right_triangle([60, 10, 40]);

right_triangle() Example 2


3. Cylindroids

cyl()

Normal Cylinders:

  • cyl(l|h, r|d, [circum], [realign], [orient], [align], [center]);
  • cyl(l|h, r1|d1, r2/d2, [circum], [realign], [orient], [align], [center]);

Chamferred Cylinders:

  • cyl(l|h, r|d, chamfer, [chamfang], [from_end], [circum], [realign], [orient], [align], [center]);
  • cyl(l|h, r|d, chamfer1, [chamfang1], [from_end], [circum], [realign], [orient], [align], [center]);
  • cyl(l|h, r|d, chamfer2, [chamfang2], [from_end], [circum], [realign], [orient], [align], [center]);
  • cyl(l|h, r|d, chamfer1, chamfer2, [chamfang1], [chamfang2], [from_end], [circum], [realign], [orient], [align], [center]);

Rounded/Filleted Cylinders:

  • cyl(l|h, r|d, fillet, [circum], [realign], [orient], [align], [center]);
  • cyl(l|h, r|d, fillet1, [circum], [realign], [orient], [align], [center]);
  • cyl(l|h, r|d, fillet2, [circum], [realign], [orient], [align], [center]);
  • cyl(l|h, r|d, fillet1, fillet2, [circum], [realign], [orient], [align], [center]);

Description: Creates cylinders in various alignments and orientations, with optional fillets and chamfers. You can use r and l interchangably, and all variants allow specifying size by either r|d, or r1|d1 and r2|d2. Note that that chamfers and fillets cannot cross the midpoint of the cylinder's length.

ArgumentWhat it does
l / hLength of cylinder along oriented axis. (Default: 1.0)
rRadius of cylinder.
r1Radius of the negative (X-, Y-, Z-) end of cylinder.
r2Radius of the positive (X+, Y+, Z+) end of cylinder.
dDiameter of cylinder.
d1Diameter of the negative (X-, Y-, Z-) end of cylinder.
d2Diameter of the positive (X+, Y+, Z+) end of cylinder.
circumIf true, cylinder should circumscribe the circle of the given size. Otherwise inscribes. Default: false
chamferThe size of the chamfers on the ends of the cylinder. Default: none.
chamfer1The size of the chamfer on the axis-negative end of the cylinder. Default: none.
chamfer2The size of the chamfer on the axis-positive end of the cylinder. Default: none.
chamfangThe angle in degrees of the chamfers on the ends of the cylinder.
chamfang1The angle in degrees of the chamfer on the axis-negative end of the cylinder.
chamfang2The angle in degrees of the chamfer on the axis-positive end of the cylinder.
from_endIf true, chamfer is measured from the end of the cylinder, instead of inset from the edge. Default: false.
filletThe radius of the fillets on the ends of the cylinder. Default: none.
fillet1The radius of the fillet on the axis-negative end of the cylinder.
fillet2The radius of the fillet on the axis-positive end of the cylinder.
realignIf true, rotate the cylinder by half the angle of one face.
orientOrientation of the cylinder. Use the ORIENT_ constants from constants.scad. Default: vertical.
alignAlignment of the cylinder. Use the V_ constants from constants.scad. Default: centered.
centerIf given, overrides align. A true value sets align=V_CENTER, false sets align=ALIGN_POS.

Example 1: By Radius

xdistribute(30) {
    cyl(l=40, r=10);
    cyl(l=40, r1=10, r2=5);
}

cyl() Example 1

Example 2: By Diameter

xdistribute(30) {
    cyl(l=40, d=25);
    cyl(l=40, d1=25, d2=10);
}

cyl() Example 2

Example 3: Chamferring

xdistribute(60) {
    // Shown Left to right.
    cyl(l=40, d=40, chamfer=7);  // Default chamfang=45
    cyl(l=40, d=40, chamfer=7, chamfang=30, from_end=false);
    cyl(l=40, d=40, chamfer=7, chamfang=30, from_end=true);
}

cyl() Example 3

Example 4: Rounding/Filleting

cyl(l=40, d=40, fillet=10);

cyl() Example 4

Example 5: Heterogenous Chamfers and Fillets

ydistribute(80) {
    // Shown Front to Back.
    cyl(l=40, d=40, fillet1=15, orient=ORIENT_X);
    cyl(l=40, d=40, chamfer2=5, orient=ORIENT_X);
    cyl(l=40, d=40, chamfer1=12, fillet2=10, orient=ORIENT_X);
}

cyl() Example 5

Example 6: Putting it all together

cyl(l=40, d1=25, d2=15, chamfer1=10, chamfang1=30, from_end=true, fillet2=5);

cyl() Example 6


downcyl()

Usage:

  • downcyl(l|h, r|d);
  • downcyl(l|h, r1|d1, r2|d2);

Description: Creates a cylinder aligned below the origin.

ArgumentWhat it does
l / hLength of cylinder. (Default: 1.0)
rRadius of cylinder.
r1Bottom radius of cylinder.
r2Top radius of cylinder.
dDiameter of cylinder. (use instead of r)
d1Bottom diameter of cylinder.
d2Top diameter of cylinder.

Example 1: Cylinder

downcyl(r=20, h=40);

downcyl() Example 1

Example 2: Cone

downcyl(r1=10, r2=20, h=40);

downcyl() Example 2


xcyl()

Usage:

  • xcyl(l|h, r|d, [align|center]);
  • xcyl(l|h, r1|d1, r2|d2, [align|center]);

Description: Creates a cylinder oriented along the X axis.

ArgumentWhat it does
l / hLength of cylinder along oriented axis. (Default: 1.0)
rRadius of cylinder.
r1Optional radius of left (X-) end of cylinder.
r2Optional radius of right (X+) end of cylinder.
dOptional diameter of cylinder. (use instead of r)
d1Optional diameter of left (X-) end of cylinder.
d2Optional diameter of right (X+) end of cylinder.
alignThe side of the origin to align to. Use V_ constants from constants.scad. Default: V_CENTER
centerIf given, overrides align. A true value sets align=V_CENTER, false sets align=ALIGN_POS.

Example 1: By Radius

ydistribute(50) {
    xcyl(l=35, r=10);
    xcyl(l=35, r1=15, r2=5);
}

xcyl() Example 1

Example 2: By Diameter

ydistribute(50) {
    xcyl(l=35, d=20);
    xcyl(l=35, d1=30, d2=10);
}

xcyl() Example 2


ycyl()

Usage:

  • ycyl(l|h, r|d, [align|center]);
  • ycyl(l|h, r1|d1, r2|d2, [align|center]);

Description: Creates a cylinder oriented along the Y axis.

ArgumentWhat it does
l / hLength of cylinder along oriented axis. (Default: 1.0)
rRadius of cylinder.
r1Radius of front (Y-) end of cone.
r2Radius of back (Y+) end of one.
dDiameter of cylinder.
d1Diameter of front (Y-) end of one.
d2Diameter of back (Y+) end of one.
alignThe side of the origin to align to. Use V_ constants from constants.scad. Default: V_CENTER
centerOverrides align if given. If true, align=V_CENTER, if false, align=ALIGN_POS.

Example 1: By Radius

xdistribute(50) {
    ycyl(l=35, r=10);
    ycyl(l=35, r1=15, r2=5);
}

ycyl() Example 1

Example 2: By Diameter

xdistribute(50) {
    ycyl(l=35, d=20);
    ycyl(l=35, d1=30, d2=10);
}

ycyl() Example 2


zcyl()

Usage:

  • zcyl(l|h, r|d, [align|center]);
  • zcyl(l|h, r1|d1, r2|d2, [align|center]);

Description: Creates a cylinder oriented along the Z axis.

ArgumentWhat it does
l / hLength of cylinder along oriented axis. (Default: 1.0)
rRadius of cylinder.
r1Radius of front (Y-) end of cone.
r2Radius of back (Y+) end of one.
dDiameter of cylinder.
d1Diameter of front (Y-) end of one.
d2Diameter of back (Y+) end of one.
alignThe side of the origin to align to. Use V_ constants from constants.scad. Default: V_CENTER
centerOverrides align if given. If true, align=V_CENTER, if false, align=ALIGN_POS.

Example 1: By Radius

xdistribute(50) {
    zcyl(l=35, r=10);
    zcyl(l=35, r1=15, r2=5);
}

zcyl() Example 1

Example 2: By Diameter

xdistribute(50) {
    zcyl(l=35, d=20);
    zcyl(l=35, d1=30, d2=10);
}

zcyl() Example 2


tube()

Usage:

  • tube(h, ir|id, wall, [realign], [orient], [align]);
  • tube(h, or|od, wall, [realign], [orient], [align]);
  • tube(h, ir|id, or|od, [realign], [orient], [align]);
  • tube(h, ir1|id1, ir2|id2, wall, [realign], [orient], [align]);
  • tube(h, or1|od1, or2|od2, wall, [realign], [orient], [align]);
  • tube(h, ir1|id1, ir2|id2, or1|od1, or2|od2, [realign], [orient], [align]);

Description: Makes a hollow tube with the given outer size and wall thickness.

ArgumentWhat it does
hheight of tube. (Default: 1)
orOuter radius of tube.
or1Outer radius of bottom of tube. (Default: value of r)
or2Outer radius of top of tube. (Default: value of r)
odOuter diameter of tube.
od1Outer diameter of bottom of tube.
od2Outer diameter of top of tube.
wallhorizontal thickness of tube wall. (Default 0.5)
irInner radius of tube.
ir1Inner radius of bottom of tube.
ir2Inner radius of top of tube.
idInner diameter of tube.
id1Inner diameter of bottom of tube.
id2Inner diameter of top of tube.
realignIf true, rotate the tube by half the angle of one face.
orientOrientation of the tube. Use the ORIENT_ constants from constants.scad. Default: vertical.
alignAlignment of the tube. Use the V_ constants from constants.scad. Default: ALIGN_POS.
centerOverrides align if given. If true, align=V_CENTER, if false, align=ALIGN_POS.

Example 1: These all Produce the Same Tube

tube(h=30, or=40, wall=5);
tube(h=30, ir=35, wall=5);
tube(h=30, or=40, ir=35);
tube(h=30, od=80, id=70);

tube() Example 1

Example 2: These all Produce the Same Conical Tube

tube(h=30, or1=40, or2=25, wall=5);
tube(h=30, ir1=35, or2=20, wall=5);
tube(h=30, or1=40, or2=25, ir1=35, ir2=20);

tube() Example 2

Example 3: Circular Wedge

tube(h=30, or1=40, or2=30, ir1=20, ir2=30);

tube() Example 3


torus()

Usage:

  • torus(r|d, r2|d2, [orient], [align]);
  • torus(or|od, ir|id, [orient], [align]);
ArgumentWhat it does
rmajor radius of torus ring. (use with of 'r2', or 'd2')
r2minor radius of torus ring. (use with of 'r', or 'd')
dmajor diameter of torus ring. (use with of 'r2', or 'd2')
d2minor diameter of torus ring. (use with of 'r', or 'd')
orouter radius of the torus. (use with 'ir', or 'id')
irinside radius of the torus. (use with 'or', or 'od')
odouter diameter of the torus. (use with 'ir' or 'id')
idinside diameter of the torus. (use with 'or' or 'od')
orientOrientation of the torus. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Z.
alignAlignment of the torus. Use the V_ constants from constants.scad. Default: V_CENTER.

Example:

// These all produce the same torus.
torus(r=22.5, r2=7.5);
torus(d=45, d2=15);
torus(or=30, ir=15);
torus(od=60, id=30);

torus() Example


4. Spheroids

staggered_sphere()

Usage:

  • staggered_sphere(r|d, [circum])

Description: An alternate construction to the standard sphere() built-in, with different triangulation.

ArgumentWhat it does
rRadius of the sphere.
dDiameter of the sphere.
circumIf true, circumscribes the perfect sphere of the given size.

Example:

staggered_sphere(d=100, circum=true, $fn=10);

staggered_sphere() Example


5. 3D Printing Shapes

teardrop2d()

Usage:

  • teardrop2d(r|d, [ang], [cap_h]);

Description: Makes a 2D teardrop shape. Useful for extruding into 3D printable holes.

ArgumentWhat it does
rradius of circular part of teardrop. (Default: 1)
ddiameter of spherical portion of bottom. (Use instead of r)
angangle of hat walls from the Y axis. (Default: 45 degrees)
cap_hif given, height above center where the shape will be truncated.

Example 1: Typical Shape

teardrop2d(r=30, ang=30);

teardrop2d() Example 1

Example 2: Crop Cap

teardrop2d(r=30, ang=30, cap_h=40);

teardrop2d() Example 2

Example 3: Close Crop

teardrop2d(r=30, ang=30, cap_h=20);

teardrop2d() Example 3


teardrop()

Usage:

  • teardrop(r|d, l|h, [ang], [cap_h], [orient], [align])

Description: Makes a teardrop shape in the XZ plane. Useful for 3D printable holes.

ArgumentWhat it does
rRadius of circular part of teardrop. (Default: 1)
dDiameter of circular portion of bottom. (Use instead of r)
lThickness of teardrop. (Default: 1)
angAngle of hat walls from the Z axis. (Default: 45 degrees)
cap_hIf given, height above center where the shape will be truncated.
orientOrientation of the shape. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example 1: Typical Shape

teardrop(r=30, h=10, ang=30);

teardrop() Example 1

Example 2: Crop Cap

teardrop(r=30, h=10, ang=30, cap_h=40);

teardrop() Example 2

Example 3: Close Crop

teardrop(r=30, h=10, ang=30, cap_h=20);

teardrop() Example 3


onion()

Usage:

  • onion(r|d, [maxang], [cap_h], [orient], [align]);

Description: Creates a sphere with a conical hat, to make a 3D teardrop.

ArgumentWhat it does
rradius of spherical portion of the bottom. (Default: 1)
ddiameter of spherical portion of bottom.
cap_hheight above sphere center to truncate teardrop shape.
maxangangle of cone on top from vertical.
orientOrientation of the shape. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example 1: Typical Shape

onion(r=30, maxang=30);

onion() Example 1

Example 2: Crop Cap

onion(r=30, maxang=30, cap_h=40);

onion() Example 2

Example 3: Close Crop

onion(r=30, maxang=30, cap_h=20);

onion() Example 3


narrowing_strut()

Usage:

  • narrowing_strut(w, l, wall, [ang], [orient], [align]);

Description: Makes a rectangular strut with the top side narrowing in a triangle. The shape created may be likened to an extruded home plate from baseball. This is useful for constructing parts that minimize the need to support overhangs.

ArgumentWhat it does
wWidth (thickness) of the strut.
lLength of the strut.
wallheight of rectangular portion of the strut.
angangle that the trianglar side will converge at.
orientOrientation of the length axis of the shape. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example:

narrowing_strut(w=10, l=100, wall=5, ang=30);

narrowing_strut() Example


thinning_wall()

Usage:

  • thinning_wall(h, l, thick, [ang], [strut], [wall], [orient], [align]);

Description: Makes a rectangular wall which thins to a smaller width in the center, with angled supports to prevent critical overhangs.

ArgumentWhat it does
hheight of wall.
llength of wall. If given as a vector of two numbers, specifies bottom and top lengths, respectively.
thickthickness of wall.
angmaximum overhang angle of diagonal brace.
strutthe width of the diagonal brace.
wallthe thickness of the thinned portion of the wall.
orientOrientation of the length axis of the wall. Use the ORIENT_ constants from constants.scad. Default: ORIENT_X.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example 1: Typical Shape

thinning_wall(h=50, l=80, thick=4);

thinning_wall() Example 1

Example 2: Trapezoidal

thinning_wall(h=50, l=[80,50], thick=4);

thinning_wall() Example 2


braced_thinning_wall()

Usage:

  • braced_thinning_wall(h, l, thick, [ang], [strut], [wall], [orient], [align]);

Description: Makes a rectangular wall with cross-bracing, which thins to a smaller width in the center, with angled supports to prevent critical overhangs.

ArgumentWhat it does
hheight of wall.
llength of wall.
thickthickness of wall.
angmaximum overhang angle of diagonal brace.
strutthe width of the diagonal brace.
wallthe thickness of the thinned portion of the wall.
orientOrientation of the length axis of the wall. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example: Typical Shape

braced_thinning_wall(h=50, l=100, thick=5);

braced_thinning_wall() Example


thinning_triangle()

Usage:

  • thinning_triangle(h, l, thick, [ang], [strut], [wall], [diagonly], [orient], [align|center]);

Description: Makes a triangular wall with thick edges, which thins to a smaller width in the center, with angled supports to prevent critical overhangs.

ArgumentWhat it does
hheight of wall.
llength of wall.
thickthickness of wall.
angmaximum overhang angle of diagonal brace.
strutthe width of the diagonal brace.
wallthe thickness of the thinned portion of the wall.
diagonlyboolean, which denotes only the diagonal side (hypotenuse) should be thick.
orientOrientation of the length axis of the shape. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.
centerIf true, centers shape. If false, overrides align with V_UP+V_BACK.

Example 1: Centered

thinning_triangle(h=50, l=80, thick=4, ang=30, strut=5, wall=2, center=true);

thinning_triangle() Example 1

Example 2: All Braces

thinning_triangle(h=50, l=80, thick=4, ang=30, strut=5, wall=2, center=false);

thinning_triangle() Example 2

Example 3: Diagonal Brace Only

thinning_triangle(h=50, l=80, thick=4, ang=30, strut=5, wall=2, diagonly=true, center=false);

thinning_triangle() Example 3


sparse_strut()

Usage:

  • sparse_strut(h, l, thick, [strut], [maxang], [max_bridge], [orient], [align])

Description: Makes an open rectangular strut with X-shaped cross-bracing, designed to reduce the need for support material in 3D printing.

ArgumentWhat it does
hheight of strut wall.
llength of strut wall.
thickthickness of strut wall.
maxangmaximum overhang angle of cross-braces.
max_bridgemaximum bridging distance between cross-braces.
strutthe width of the cross-braces.
orientOrientation of the length axis of the shape. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example 1: Typical Shape

sparse_strut(h=40, l=100, thick=3);

sparse_strut() Example 1

Example 2: Thinner Strut

sparse_strut(h=40, l=100, thick=3, strut=2);

sparse_strut() Example 2

Example 3: Larger maxang

sparse_strut(h=40, l=100, thick=3, strut=2, maxang=45);

sparse_strut() Example 3

Example 4: Longer max_bridge

sparse_strut(h=40, l=100, thick=3, strut=2, maxang=45, max_bridge=30);

sparse_strut() Example 4


sparse_strut3d()

Usage:

  • sparse_strut3d(h, w, l, [thick], [maxang], [max_bridge], [strut], [orient], [align]);

Description: Makes an open rectangular strut with X-shaped cross-bracing, designed to reduce the need for support material in 3D printing.

ArgumentWhat it does
hZ size of strut.
wX size of strut.
lY size of strut.
thickthickness of strut walls.
maxangmaximum overhang angle of cross-braces.
max_bridgemaximum bridging distance between cross-braces.
strutthe width of the cross-braces.
orientOrientation of the length axis of the shape. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example 1: Typical Shape

sparse_strut3d(h=30, w=30, l=100);

sparse_strut3d() Example 1

Example 2: Thinner strut

sparse_strut3d(h=30, w=30, l=100, strut=2);

sparse_strut3d() Example 2

Example 3: Larger maxang

sparse_strut3d(h=30, w=30, l=100, strut=2, maxang=50);

sparse_strut3d() Example 3

Example 4: Smaller max_bridge

sparse_strut3d(h=30, w=30, l=100, strut=2, maxang=50, max_bridge=20);

sparse_strut3d() Example 4


corrugated_wall()

Usage:

  • corrugated_wall(h, l, thick, [strut], [wall], [orient], [align]);

Description: Makes a corrugated wall which relieves contraction stress while still providing support strength. Designed with 3D printing in mind.

ArgumentWhat it does
hheight of strut wall.
llength of strut wall.
thickthickness of strut wall.
strutthe width of the cross-braces.
wallthickness of corrugations.
orientOrientation of the length axis of the shape. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Y.
alignAlignment of the shape. Use the V_ constants from constants.scad. Default: V_CENTER.

Example 1: Typical Shape

corrugated_wall(h=50, l=100);

corrugated_wall() Example 1

Example 2: Wider Strut

corrugated_wall(h=50, l=100, strut=8);

corrugated_wall() Example 2

Example 3: Thicker Wall

corrugated_wall(h=50, l=100, strut=8, wall=3);

corrugated_wall() Example 3


6. Miscellaneous

nil()

Description: Useful when you MUST pass a child to a module, but you want it to be nothing.


noop()

Description: Passes through the children passed to it, with no action at all. Useful while debugging when you want to replace a command.


pie_slice()

Usage:

  • pie_slice(ang, l|h, r|d, [orient], [align|center]);
  • pie_slice(ang, l|h, r1|d1, r2|d2, [orient], [align|center]);

Description: Creates a pie slice shape.

ArgumentWhat it does
angpie slice angle in degrees.
hheight of pie slice.
rradius of pie slice.
r1bottom radius of pie slice.
r2top radius of pie slice.
ddiameter of pie slice.
d1bottom diameter of pie slice.
d2top diameter of pie slice.
orientOrientation of the pie slice. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Z.
alignAlignment of the pie slice. Use the V_ constants from constants.scad. Default: V_CENTER.
centerIf given, overrides align. A true value sets align=V_CENTER, false sets align=ALIGN_POS.

Example 1: Cylindrical Pie Slice

pie_slice(ang=45, l=20, r=30);

pie_slice() Example 1

Example 2: Conical Pie Slice

pie_slice(ang=60, l=20, d1=50, d2=70);

pie_slice() Example 2


interior_fillet()

Usage:

  • interior_fillet(l, r, [ang], [overlap], [orient], [align]);

Description: Creates a shape that can be unioned into a concave joint between two faces, to fillet them. Center this part along the concave edge to be chamferred and union it in.

ArgumentWhat it does
llength of edge to fillet.
rradius of fillet.
angangle between faces to fillet.
overlapoverlap size for unioning with faces.
orientOrientation of the fillet. Use the ORIENT_ constants from constants.scad. Default: ORIENT_X.
alignAlignment of the fillet. Use the V_ or ALIGN_ constants from constants.scad. Default: V_CENTER.

Example 1:

union() {
    translate([0,2,-4]) upcube([20, 4, 24]);
    translate([0,-10,-4]) upcube([20, 20, 4]);
    color("green") interior_fillet(l=20, r=10, orient=ORIENT_XNEG);
}

interior_fillet() Example 1

Example 2:

interior_fillet(l=40, r=10, orient=ORIENT_Y_90);

interior_fillet() Example 2


slot()

Usage:

  • slot(h, l, r|d, [orient], [align|center]);
  • slot(h, p1, p2, r|d, [orient], [align|center]);
  • slot(h, l, r1|d1, r2|d2, [orient], [align|center]);
  • slot(h, p1, p2, r1|d1, r2|d2, [orient], [align|center]);

Description: Makes a linear slot with rounded ends, appropriate for bolts to slide along.

ArgumentWhat it does
p1center of starting circle of slot.
p2center of ending circle of slot.
ldistance between center points of starting and ending circle.
hheight of slot shape. (default: 10)
rradius of slot circle. (default: 5)
r1bottom radius of slot cone.
r2top radius of slot cone.
ddiameter of slot circle.
d1bottom diameter of slot cone.
d2top diameter of slot cone.

Example 1: Between Two Points

slot([0,0,0], [50,50,0], r1=5, r2=10, h=5);

slot() Example 1

Example 2: By Length

slot(l=50, r1=5, r2=10, h=5);

slot() Example 2


arced_slot()

Usage:

  • arced_slot(h, r|d, sr|sd, [sa], [ea], [orient], [align|center], [$fn2]);
  • arced_slot(h, r|d, sr1|sd1, sr2|sd2, [sa], [ea], [orient], [align|center], [$fn2]);

Description: Makes an arced slot, appropriate for bolts to slide along.

ArgumentWhat it does
cpcenterpoint of slot arc. (default: [0, 0, 0])
hheight of slot arc shape. (default: 1.0)
rradius of slot arc. (default: 0.5)
ddiameter of slot arc. (default: 1.0)
srradius of slot channel. (default: 0.5)
sddiameter of slot channel. (default: 0.5)
sr1bottom radius of slot channel cone. (use instead of sr)
sr2top radius of slot channel cone. (use instead of sr)
sd1bottom diameter of slot channel cone. (use instead of sd)
sd2top diameter of slot channel cone. (use instead of sd)
sastarting angle. (Default: 0.0)
eaending angle. (Default: 90.0)
orientOrientation of the arced slot. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Z.
alignAlignment of the arced slot. Use the V_ constants from constants.scad. Default: V_CENTER.
centerIf true, centers vertically. If false, drops flush with XY plane. Overrides align.
$fn2The $fn value to use on the small round endcaps. The major arcs are still based on $fn. Default: $fn

Example 1: Typical Arced Slot

arced_slot(d=60, h=5, sd=10, sa=60, ea=280);

arced_slot() Example 1

Example 2: Conical Arced Slot

arced_slot(r=60, h=5, sd1=10, sd2=15, sa=45, ea=180);

arced_slot() Example 2


7. Deprecations

cube2pt()

DEPRECATED, use cuboid(p1,p2) instead.

Usage:

  • cube2pt(p1,p2)

Description: Creates a cube between two points.

ArgumentWhat it does
p1Coordinate point of one cube corner.
p2Coordinate point of opposite cube corner.

offsetcube()

DEPRECATED, use cuboid(..., align) instead.

Description: Makes a cube that is offset along the given vector by half the cube's size. For example, if v=[-1,1,0], the cube's front right edge will be centered at the origin.

ArgumentWhat it does
sizesize of cube.
vvector to offset along.

chamfcube()

DEPRECATED, use cuboid(..., chamfer, edges, trimcorners) instead.

Description: Makes a cube with chamfered edges.

ArgumentWhat it does
sizeSize of cube [X,Y,Z]. (Default: [1,1,1])
chamferChamfer inset along axis. (Default: 0.25)
chamfaxesArray [X,Y,Z] of boolean values to specify which axis edges should be chamfered.
chamfcornersBoolean to specify if corners should be flat chamferred.

rrect()

DEPRECATED, use cuboid(..., fillet, edges) instead.

Description: Makes a cube with rounded (filletted) vertical edges. The r size will be limited to a maximum of half the length of the shortest XY side.

ArgumentWhat it does
sizeSize of cube [X,Y,Z]. (Default: [1,1,1])
rRadius of edge/corner rounding. (Default: 0.25)
centerIf true, object will be centered. If false, sits on top of XY plane.

rcube()

DEPRECATED, use cuboid(..., fillet) instead.

Description: Makes a cube with rounded (filletted) edges and corners. The r size will be limited to a maximum of half the length of the shortest cube side.

ArgumentWhat it does
sizeSize of cube [X,Y,Z]. (Default: [1,1,1])
rRadius of edge/corner rounding. (Default: 0.25)
centerIf true, object will be centered. If false, sits on top of XY plane.

trapezoid()

DEPRECATED, use prismoid() instead.

Usage:

  • trapezoid(size1, size2, h, [shift], [orient], [align|center]);

Description: Creates a rectangular prismoid shape.

ArgumentWhat it does
size1[width, length] of the axis-negative end of the prism.
size2[width, length] of the axis-positive end of the prism.
hHeight of the prism.
shift[x, y] amount to shift the center of the top with respect to the center of the bottom.
orientOrientation of the prismoid. Use the ORIENT_ constants from constants.scad. Default: ORIENT_Z.
alignAlignment of the prismoid by the axis-negative (size1) end. Use the V_ constants from constants.scad. Default: V_UP
centerIf given, overrides align. A true value sets align=V_CENTER, false sets align=V_UP.

pyramid()

DEPRECATED, use cyl(, r2=0, $fn=N) instead.

Usage:

  • pyramid(n, h, l|r|d, [circum]);

Description: Creates a pyramidal prism with a given number of sides.

ArgumentWhat it does
nnumber of pyramid sides.
hheight of the pyramid.
llength of one side of the pyramid. (optional)
rradius of the base of the pyramid. (optional)
ddiameter of the base of the pyramid. (optional)
circumbase circumscribes the circle of the given radius or diam.

prism()

DEPRECATED, use cyl(..., $fn=N) instead.

Usage:

  • prism(n, h, l|r|d, [circum]);

Description: Creates a vertical prism with a given number of sides.

ArgumentWhat it does
nnumber of sides.
hheight of the prism.
llength of one side of the prism. (optional)
rradius of the prism. (optional)
ddiameter of the prism. (optional)
circumprism circumscribes the circle of the given radius or diam.

chamferred_cylinder()

DEPRECATED, use cyl(..., chamfer) instead.

Usage:

  • chamferred_cylinder(h, r|d, chamfer|chamfedge, [top], [bottom], [center])

Description: Creates a cylinder with chamferred (bevelled) edges.

ArgumentWhat it does
hheight of cylinder. (Default: 1.0)
rradius of cylinder. (Default: 1.0)
ddiameter of cylinder. (use instead of r)
chamferradial inset of the edge chamfer. (Default: 0.25)
chamfedgelength of the chamfer edge. (Use instead of chamfer)
topboolean. If true, chamfer the top edges. (Default: True)
bottomboolean. If true, chamfer the bottom edges. (Default: True)
centerboolean. If true, cylinder is centered. (Default: false)

chamf_cyl()

DEPRECATED, use cyl(..., chamfer) instead.

Usage:

  • chamf_cyl(h, r|d, chamfer|chamfedge, [top], [bottom], [center])

Description: Creates a cylinder with chamferred (bevelled) edges. Basically a shortcut of chamferred_cylinder()

ArgumentWhat it does
hheight of cylinder. (Default: 1.0)
rradius of cylinder. (Default: 1.0)
ddiameter of cylinder. (use instead of r)
chamferradial inset of the edge chamfer. (Default: 0.25)
chamfedgelength of the chamfer edge. (Use instead of chamfer)
topboolean. If true, chamfer the top edges. (Default: True)
bottomboolean. If true, chamfer the bottom edges. (Default: True)
centerboolean. If true, cylinder is centered. (Default: false)

filleted_cylinder()

DEPRECATED, use cyl(..., fillet) instead.

Usage:

  • filleted_cylinder(h, r|d, fillet, [center]);

Description: Creates a cylinder with filletted (rounded) ends.

ArgumentWhat it does
hheight of cylinder. (Default: 1.0)
rradius of cylinder. (Default: 1.0)
ddiameter of cylinder. (Use instead of r)
filletradius of the edge filleting. (Default: 0.25)
centerboolean. If true, cylinder is centered. (Default: false)

rcylinder()

DEPRECATED, use cyl(..., fillet) instead.

Usage:

  • rcylinder(h, r|d, fillet, [center]);

Description: Creates a cylinder with filletted (rounded) ends. Basically a shortcut for filleted_cylinder().

ArgumentWhat it does
hheight of cylinder. (Default: 1.0)
rradius of cylinder. (Default: 1.0)
ddiameter of cylinder. (Use instead of r)
filletradius of the edge filleting. (Default: 0.25)
centerboolean. If true, cylinder is centered. (Default: false)

thinning_brace()

DEPRECATED, use thinning_triangle(..., diagonly=true) instead.

Usage:

  • thinning_brace(h, l, thick, [ang], [strut], [wall], [center])

Description: Makes a triangular wall which thins to a smaller width in the center, with angled supports to prevent critical overhangs. Basically an alias of thinning_triangle(), with diagonly=true.

ArgumentWhat it does
hheight of wall.
llength of wall.
thickthickness of wall.
angmaximum overhang angle of diagonal brace.
strutthe width of the diagonal brace.
wallthe thickness of the thinned portion of the wall.