Skip to content

Instantly share code, notes, and snippets.

@medicationforall
Created September 3, 2022 12:14
Show Gist options
  • Save medicationforall/d7841e5cbb405d4f7168cd8fb5c278b8 to your computer and use it in GitHub Desktop.
Save medicationforall/d7841e5cbb405d4f7168cd8fb5c278b8 to your computer and use it in GitHub Desktop.
# Copyright 2022 James Adams
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import cadquery as cq
def __cut_slot(shape, size):
chamfer_size = size*.4
height = shape.val().BoundingBox().zlen
slots = shape.faces("|Y").box(size, size, height, combine=False)
slots = slots.edges("Z").chamfer(chamfer_size)
return shape.cut(slots)
def __inner_door(length, width, height):
door = cq.Workplane("XY").box(length, width, height)
door = __cut_slot(door, 1.5)
return door
def __outer_frame(outline, length, frame_length, width, height, frame_height):
frame_cut = cq.Workplane("XY").box(length-frame_length, width, height - frame_height).translate((0,0,-1*(frame_height/2)))
frame = outline.cut(frame_cut)
return frame
def make_door(length=25, width=8, frame_length=3, frame_height=4, inner_width=3, height=40):
outline = cq.Workplane("XY").box(length, width,height)
frame = __outer_frame(outline, length, frame_length, width, height, frame_height)
frame = frame.chamfer(.7)
door = __inner_door(length-frame_length, inner_width, height - frame_height).translate((0,0,-1*(frame_height/2)))
combined = frame.union(door)
#return [combined]
#return [ frame, door, combined]
return [outline, frame, door, combined]
length = 25
width = 6
inner_width=2
frame_length=3
height=40
parts = make_door(length, width,frame_length=frame_length, inner_width=inner_width, height=height)
scene = cq.Workplane("XY")
for index, part in enumerate(parts):
x_t = length+5
scene.add(part.translate((x_t*index,0,0)))
show_object(scene.translate((0,0,height/2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment