Skip to content

Instantly share code, notes, and snippets.

@rolandcrosby
Created June 2, 2019 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolandcrosby/fad0a20a1ce77b66ba3c0dde27b5561b to your computer and use it in GitHub Desktop.
Save rolandcrosby/fad0a20a1ce77b66ba3c0dde27b5561b to your computer and use it in GitHub Desktop.
SketchUp script to generate cabinet door/drawer fronts in the style of Reform's Basis design
def basis_door(width, height, cx=2.0, cy=2.0)
# Measurements from https://www.reformcph.com/us/design/basis/
lin_depth = 5.0/64
oak_depth = 3.0/4
hole_depth = 5.0/8
radius = (1 + 5.0/8) / 2
model = Sketchup.active_model
door = model.active_entities.add_group
linoleum = door.entities.add_group
lin_entities = linoleum.entities
front = lin_entities.add_face(
[0, 0, 0],
[width, 0, 0],
[width, 0, height],
[0, 0, height],
[0, 0, 0]
)
circle = lin_entities.add_circle([cx, 0, cy], Geom::Vector3d.new(0, 1, 0), radius)
circle[0].all_connected.find {|x| x.instance_of?(Sketchup::Face) && x != front}.erase!
front.pushpull(-lin_depth)
oak = door.entities.add_group
oak_entities = oak.entities
front = oak_entities.add_face(
[0, lin_depth, 0],
[width, lin_depth, 0],
[width, lin_depth, height],
[0, lin_depth, height],
[0, lin_depth, 0]
)
front.pushpull(lin_depth - oak_depth)
circle = oak_entities.add_circle([cx, lin_depth, cy], Geom::Vector3d.new(0, 1, 0), 1)
circle[0].find_faces
cutout = circle[0].all_connected.find {|x| x.instance_of?(Sketchup::Face) && x != front}
cutout.pushpull(lin_depth - hole_depth)
oak_entities.grep(Sketchup::Face).each {|f| f.material = "#D3CCAC"}
model.selection.add(door)
return door
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment