Skip to content

Instantly share code, notes, and snippets.

@jwygralak67
Last active December 10, 2015 14:50
Show Gist options
  • Save jwygralak67/4450435 to your computer and use it in GitHub Desktop.
Save jwygralak67/4450435 to your computer and use it in GitHub Desktop.
Using the Subtract transformation in CoffeeScad to create a thru-hole or a hollow object.
# How to create a hole
# First, create the object we want to put a hole in
disc = new Cylinder
d: 100
h: 10
center: true
# Next, create a cylinder the size of the hole
hole = new Cylinder
d: 25
h: 11
center: true
# Finally, using the subtract transformation, subtract
# the cylinder from the disc, leaving a disc with a
# hole in the middle
holeyDisc = disc.subtract(hole)
return holeyDisc
# How to create a hollow box
# First, create a rectangle the size of the box.
box = new Cube
size: [60,40,20]
center: [0,0,10] # Move the box up so it sits on the XY plane
# Next, create a rectangle the size of the inside.
hole = new Cube
size: [55,35,18]
center: [0,0,11.5] # This size and position will leave a 2.5 unit thick wall and bottom.
# Finally, using the subtract transformation, subtract
# the inside from the outside
box = box.subtract(hole)
return box
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment