diff --git a/belt_rivets.py b/belt_rivets.py index 4d834c5..baba3ea 100644 --- a/belt_rivets.py +++ b/belt_rivets.py @@ -13,9 +13,9 @@ import cqmore Workplane = cqmore.extend(Workplane) Workplane.addSvgPath = addSvgPath -#wk_paths, wk_attributes = svg2paths( - #"/home/deck/cad_files/svgs/wk_edited.svg" -#) +# wk_paths, wk_attributes = svg2paths( +# "/home/deck/cad_files/svgs/wk_edited.svg" +# ) inner_radius = 5 outer_radius = 7 @@ -36,47 +36,115 @@ slide_width_bottom = loop_side_thickness - 3 slide_width_top = loop_side_thickness - 4 logo = Workplane().circle(outer_radius).extrude(thickness) -logo = logo.faces(">Z[0]").circle(inner_radius+0.9).extrude(thickness, combine="cut") +logo = logo.faces(">Z[0]").circle(inner_radius + 0.9).extrude(thickness, combine="cut") logo = logo.faces(">Z[0]").circle(inner_radius).extrude(thickness) -logo = logo.faces(">Z[1]").center(0,0).cylinder(thickness+2, inner_radius-1, combine="cut") -logo = logo.workplane(offset=1.0).circle(outer_radius+4).extrude(1).workplane(offset=0.5).text("WK", 10, 0.8, combine="cut") - -#wk = Workplane("XY").center(0, 0).addSvgPath(wk_paths[0]).extrude(-2.0) - -#logo = logo.union(wk, clean=False) - -logo_outer = Workplane().circle(inner_radius+1).extrude(thickness) -logo_outer = logo_outer.faces(">Z[0]").circle(inner_radius).extrude(thickness, combine="cut") -logo_outer = logo_outer.workplane(offset=1.0).circle(outer_radius+4).extrude(1) +logo = ( + logo.faces(">Z[1]") + .center(0, 0) + .cylinder(thickness + 2, inner_radius - 1, combine="cut") +) +logo = ( + logo.workplane(offset=1.0) + .circle(outer_radius + 4) + .extrude(1) + .workplane(offset=0.5) + .text("WK", 10, 0.8, combine="cut") +) + +# wk = Workplane("XY").center(0, 0).addSvgPath(wk_paths[0]).extrude(-2.0) + +# logo = logo.union(wk, clean=False) + +logo_outer = Workplane().circle(inner_radius + 1).extrude(thickness) +logo_outer = ( + logo_outer.faces(">Z[0]").circle(inner_radius).extrude(thickness, combine="cut") +) +logo_outer = logo_outer.workplane(offset=1.0).circle(outer_radius + 4).extrude(1) cq.exporters.export(logo, "/home/deck/model_files/belt_hole_inner.step") cq.exporters.export(logo_outer, "/home/deck/model_files/belt_hole_outer.step") rivet = Workplane().circle(rivet_outer_radius).extrude(rivet_thickness) -rivet = rivet.faces(">Z[0]").circle(rivet_inner_radius+1.10).extrude(rivet_thickness, combine="cut") -rivet = rivet.faces(">Z[0]").circle(rivet_inner_radius-0.15).extrude(rivet_thickness) -rivet = rivet.faces(">Z[1]").center(0,0).cylinder(rivet_thickness+2, rivet_inner_radius-1, combine="cut") -rivet = rivet.workplane(offset=1.0).circle(rivet_outer_radius+1).extrude(1) - -rivet_outer = Workplane().circle(rivet_inner_radius+0.4).extrude(rivet_thickness) -rivet_outer = rivet_outer.faces(">Z[0]").circle(rivet_inner_radius).extrude(rivet_thickness, combine="cut") -rivet_outer = rivet_outer.workplane(offset=1.0).circle(rivet_outer_radius+1).extrude(1) +rivet = ( + rivet.faces(">Z[0]") + .circle(rivet_inner_radius + 1.10) + .extrude(rivet_thickness, combine="cut") +) +rivet = rivet.faces(">Z[0]").circle(rivet_inner_radius - 0.15).extrude(rivet_thickness) +rivet = ( + rivet.faces(">Z[1]") + .center(0, 0) + .cylinder(rivet_thickness + 2, rivet_inner_radius - 1, combine="cut") +) +rivet = rivet.workplane(offset=1.0).circle(rivet_outer_radius + 1).extrude(1) + +rivet_outer = Workplane().circle(rivet_inner_radius + 0.4).extrude(rivet_thickness) +rivet_outer = ( + rivet_outer.faces(">Z[0]") + .circle(rivet_inner_radius) + .extrude(rivet_thickness, combine="cut") +) +rivet_outer = ( + rivet_outer.workplane(offset=1.0).circle(rivet_outer_radius + 1).extrude(1) +) loop = Workplane().box(loop_length, loop_width, loop_height) -loop_cut = Workplane().box(loop_length-loop_thickness-loop_side_thickness, loop_width, loop_height-loop_thickness) +loop_cut = Workplane().box( + loop_length - loop_thickness - loop_side_thickness, + loop_width, + loop_height - loop_thickness, +) loop = loop.cut(loop_cut) loop_top = loop.faces(">Z[0]").workplane(offset=-1.8).split(keepTop=True) loop_bottom = loop.faces(">Z[0]").workplane(offset=-1).split(keepBottom=True) -slide_bottom_cut_left = Workplane().move(-((loop_length/2)-loop_thickness), 0).box(slide_width_bottom, loop_width, 2) -slide_bottom_cut_right = Workplane().move(((loop_length/2)-loop_thickness), 0).box(slide_width_bottom, loop_width, 2) -slide_top_cut_left = Workplane().workplane(offset=-2.8).move(-((loop_length/2)-loop_thickness), 0).box(slide_width_top, loop_width, loop_height/2) -slide_top_cut_right = Workplane().workplane(offset=-2.8).move(((loop_length/2)-loop_thickness), 0).box(slide_width_top, loop_width, loop_height/2) - -slide_bottom_union_left = Workplane().workplane(offset=1).move(-((loop_length/2)-loop_thickness), 0).box(slide_width_bottom-0.3, loop_width, 1.8) -slide_bottom_union_right = Workplane().workplane(offset=1).move(((loop_length/2)-loop_thickness), 0).box(slide_width_bottom-0.3, loop_width, 1.8) -slide_top_union_left = Workplane().workplane(offset=-1.8).move(-((loop_length/2)-loop_thickness), 0).box(slide_width_top, loop_width, loop_height/2) -slide_top_union_right = Workplane().workplane(offset=-1.8).move(((loop_length/2)-loop_thickness), 0).box(slide_width_top, loop_width, loop_height/2) +slide_bottom_cut_left = ( + Workplane() + .move(-((loop_length / 2) - loop_thickness), 0) + .box(slide_width_bottom, loop_width, 2) +) +slide_bottom_cut_right = ( + Workplane() + .move(((loop_length / 2) - loop_thickness), 0) + .box(slide_width_bottom, loop_width, 2) +) +slide_top_cut_left = ( + Workplane() + .workplane(offset=-2.8) + .move(-((loop_length / 2) - loop_thickness), 0) + .box(slide_width_top, loop_width, loop_height / 2) +) +slide_top_cut_right = ( + Workplane() + .workplane(offset=-2.8) + .move(((loop_length / 2) - loop_thickness), 0) + .box(slide_width_top, loop_width, loop_height / 2) +) + +slide_bottom_union_left = ( + Workplane() + .workplane(offset=1) + .move(-((loop_length / 2) - loop_thickness), 0) + .box(slide_width_bottom - 0.3, loop_width, 1.8) +) +slide_bottom_union_right = ( + Workplane() + .workplane(offset=1) + .move(((loop_length / 2) - loop_thickness), 0) + .box(slide_width_bottom - 0.3, loop_width, 1.8) +) +slide_top_union_left = ( + Workplane() + .workplane(offset=-1.8) + .move(-((loop_length / 2) - loop_thickness), 0) + .box(slide_width_top, loop_width, loop_height / 2) +) +slide_top_union_right = ( + Workplane() + .workplane(offset=-1.8) + .move(((loop_length / 2) - loop_thickness), 0) + .box(slide_width_top, loop_width, loop_height / 2) +) loop_bottom = loop_bottom.cut(slide_bottom_cut_left) loop_bottom = loop_bottom.cut(slide_bottom_cut_right) @@ -88,7 +156,12 @@ loop_top = loop_top.union(slide_bottom_union_right) loop_top = loop_top.union(slide_top_union_left) loop_top = loop_top.union(slide_top_union_right) -loop_top = loop_top.faces(">Z[0]").rect(loop_width, loop_height, forConstruction=True).vertices().hole((rivet_outer_radius*2)+1) +loop_top = ( + loop_top.faces(">Z[0]") + .rect(loop_width, loop_height, forConstruction=True) + .vertices() + .hole((rivet_outer_radius * 2) + 1) +) cq.exporters.export(rivet, "/home/deck/model_files/rivet_inner.step") cq.exporters.export(rivet_outer, "/home/deck/model_files/rivet_outer.step") @@ -96,9 +169,9 @@ cq.exporters.export(loop_bottom, "/home/deck/model_files/loop_bottom.step") cq.exporters.export(loop_top, "/home/deck/model_files/loop_top.step") try: - #show_object(rivet_outer) - #show_object(rivet) - #show_object(loop_bottom) - #show_object(loop_top) + show_object(rivet_outer) + # show_object(rivet) + # show_object(loop_bottom) + # show_object(loop_top) except NameError: pass diff --git a/coaster.py b/coaster.py index ca5736c..24c8928 100755 --- a/coaster.py +++ b/coaster.py @@ -8,50 +8,67 @@ xmas_tree_offset = -35 xmas_tree_height = 12 xmas_tree_width = 12 + def makeTriangle(self, width, height, x_offset=0, y_offset=0): - return (self.moveTo(x_offset-(width), y_offset).makePolygon( - [ - (0,0,0),(width,height,0), (width*2,0,0), - ] - ) - .cutBlind(30) - .clean()) + return ( + self.moveTo(x_offset - (width), y_offset) + .makePolygon( + [ + (0, 0, 0), + (width, height, 0), + (width * 2, 0, 0), + ] + ) + .cutBlind(30) + .clean() + ) + def makeXmasTree(self): - return (self.center(0,0) - .triangle(xmas_tree_width, xmas_tree_height, y_offset=-(xmas_tree_offset)) - .triangle(xmas_tree_width+3, xmas_tree_height+3, y_offset=-(xmas_tree_offset+8)) - .triangle(xmas_tree_width+1, xmas_tree_height+13, y_offset=-(xmas_tree_offset+15)) - .triangle(xmas_tree_width-2, xmas_tree_height+16, y_offset=-(xmas_tree_offset+20)) - .moveTo(0, -(xmas_tree_offset+22)) - .rect(5,8) - .cutBlind(30)) - + return ( + self.center(0, 0) + .triangle(xmas_tree_width, xmas_tree_height, y_offset=-(xmas_tree_offset)) + .triangle( + xmas_tree_width + 3, xmas_tree_height + 3, y_offset=-(xmas_tree_offset + 8) + ) + .triangle( + xmas_tree_width + 1, + xmas_tree_height + 13, + y_offset=-(xmas_tree_offset + 15), + ) + .triangle( + xmas_tree_width - 2, + xmas_tree_height + 16, + y_offset=-(xmas_tree_offset + 20), + ) + .moveTo(0, -(xmas_tree_offset + 22)) + .rect(5, 8) + .cutBlind(30) + ) + + Workplane.triangle = makeTriangle Workplane.xmasTree = makeXmasTree -polygon = (Workplane() - .makePolygon( - regularPolygon( - nSides = 16, - radius = coaster_radius, - thetaStart = 0, - thetaEnd = 360 - ) - ) - .extrude(10) - .xmasTree() - .workplane() - ) - -text_solid = (Workplane() - .text("David Kerfoot", - 25, 25, - clean=False, - combine=False, - fontPath="/home/wes/fonts/StackyardPersonalUse-16Dj.ttf") - ) +polygon = ( + Workplane() + .makePolygon( + regularPolygon(nSides=16, radius=coaster_radius, thetaStart=0, thetaEnd=360) + ) + .extrude(10) + .xmasTree() + .workplane() +) + +text_solid = Workplane().text( + "David Kerfoot", + 25, + 25, + clean=False, + combine=False, + fontPath="/home/wes/fonts/StackyardPersonalUse-16Dj.ttf", +) result = polygon.cut(text_solid) diff --git a/dice.py b/dice.py index ed7fbee..b1b2ee3 100644 --- a/dice.py +++ b/dice.py @@ -9,18 +9,20 @@ from cad_utilities.shapes import makeDice from typing import cast from cadquery import Face from cqmore import Workplane -from cqmore.polyhedron import tetrahedron, hexahedron, octahedron, dodecahedron, icosahedron +from cqmore.polyhedron import ( + tetrahedron, + hexahedron, + octahedron, + dodecahedron, + icosahedron, +) radius = 20 -font_name = 'Arial Black' +font_name = "Arial Black" font_distance = 2 detail = 0 -dice = (Workplane() - .polyhedron( - *icosahedron(radius, detail) - ) - ) +dice = Workplane().polyhedron(*icosahedron(radius, detail)) faces = dice.faces().vals() nums = len(faces) @@ -31,20 +33,19 @@ for i in range(nums): text_to_write = "20" font_size = 8.5 else: - text_to_write = str(nums-i) + text_to_write = str(nums - i) font_size = 8.5 texts.add( Workplane(faces[i]) - .workplane(origin = cast(Face, faces[i]).Center()) - .text( - text_to_write, - font_size, - -font_distance, - fontPath="/home/deck/fonts/SEVESBRG.TTF" - ) + .workplane(origin=cast(Face, faces[i]).Center()) + .text( + text_to_write, + font_size, + -font_distance, + fontPath="/home/deck/fonts/SEVESBRG.TTF", + ) ) dice = dice.cut(texts) cq.exporters.export(dice, "/home/deck/model_files/dice.step") - diff --git a/enclosure.py b/enclosure.py index f2fcd2d..d53d324 100755 --- a/enclosure.py +++ b/enclosure.py @@ -20,15 +20,15 @@ end_socket_height = 22.6 # the distance from the side of the socket to the edge of the box # for the socket that powers the relay coil -end_socket_distance_from_side = 3.47 + 3 # add 3mm for tape +end_socket_distance_from_side = 3.47 + 3 # add 3mm for tape reset_button_dist_from_socket = 5.27 reset_width = 18.7 reset_height = 35.04 -reset_lip_height = 3.37 # probably not needed +reset_lip_height = 3.37 # probably not needed # parameter definitions -p_outerWidth = relay_x_size + 15 # Outer width of box enclosure +p_outerWidth = relay_x_size + 15 # Outer width of box enclosure p_outerLength = relay_y_size # Outer length of box enclosure p_outerHeight = 33.6 + 30 # Outer height of box enclosure @@ -100,23 +100,29 @@ box = ( .all() ) # splits into two solids -lid = (lid.workplane() - .rect(socket_width+socket_distance_x, socket_distance_y+(socket_width), - forConstruction=True) - .tag("sockets") - .vertices() - .rect(socket_width, socket_width) - .cutThruAll()) +lid = ( + lid.workplane() + .rect( + socket_width + socket_distance_x, + socket_distance_y + (socket_width), + forConstruction=True, + ) + .tag("sockets") + .vertices() + .rect(socket_width, socket_width) + .cutThruAll() +) -bottom = (bottom - .faces(">Y") - .workplane() - .center(0, -end_socket_height+8) - .rect(end_socket_width, end_socket_height) - .cutBlind("next")) +bottom = ( + bottom.faces(">Y") + .workplane() + .center(0, -end_socket_height + 8) + .rect(end_socket_width, end_socket_height) + .cutBlind("next") +) -#lid = (lid.center(socket_width-8, socket_distance_y+(socket_width)-3) +# lid = (lid.center(socket_width-8, socket_distance_y+(socket_width)-3) # .rect(reset_height, reset_width) # .cutThruAll()) diff --git a/light_holder.py b/light_holder.py index 8fa4c3c..430a650 100644 --- a/light_holder.py +++ b/light_holder.py @@ -27,27 +27,50 @@ clip_thickness = 15 clip_length = 65 clip_width = 60 -clip_distance_from_sensor = 90 # how far it is from the enclosure - -result = (Workplane(). - box(outer_len, outer_width, outer_thickness) - .edges("|Z").fillet(0.9)) - - -result = result.moveTo(outer_width-recess_width, 0).rect(recess_width, recess_height).extrude(5) -result = result.moveTo(-outer_width+recess_width, 0).rect(recess_width, recess_height).extrude(5) -result = result.workplane(offset=-(outer_thickness/2)-0.33).moveTo(-outer_len/2, 0).rect(clip_length/2, clip_width).extrude(outer_thickness) -result = result.workplane(offset=-0.33).moveTo(inner_height+(clip_length/2.0)-1, 0).box(clip_width/1.8, clip_width/2.5, outer_thickness).moveTo(outer_len/2+26, 0).cylinder(10, 5/2, combine="cut") -result = result.moveTo(outer_len/2.4+30, 0).cylinder(10, 12/2, combine="cut") +clip_distance_from_sensor = 90 # how far it is from the enclosure + +result = ( + Workplane().box(outer_len, outer_width, outer_thickness).edges("|Z").fillet(0.9) +) + + +result = ( + result.moveTo(outer_width - recess_width, 0) + .rect(recess_width, recess_height) + .extrude(5) +) +result = ( + result.moveTo(-outer_width + recess_width, 0) + .rect(recess_width, recess_height) + .extrude(5) +) +result = ( + result.workplane(offset=-(outer_thickness / 2) - 0.33) + .moveTo(-outer_len / 2, 0) + .rect(clip_length / 2, clip_width) + .extrude(outer_thickness) +) +result = ( + result.workplane(offset=-0.33) + .moveTo(inner_height + (clip_length / 2.0) - 1, 0) + .box(clip_width / 1.8, clip_width / 2.5, outer_thickness) + .moveTo(outer_len / 2 + 26, 0) + .cylinder(10, 5 / 2, combine="cut") +) +result = result.moveTo(outer_len / 2.4 + 30, 0).cylinder(10, 12 / 2, combine="cut") result = result.faces(">Z[0]").moveTo(-70, 0).rect(10, clip_width).extrude(clip_length) -result = (result.faces(">Z[1]").moveTo(0,0) - .rect(outer_len-hole_dist_from_short-hole_diameter*2, - outer_width-hole_dist_from_long-hole_diameter*3, - forConstruction=True) - .vertices().cylinder(outer_thickness*3, hole_diameter/2, combine="cut")) - - +result = ( + result.faces(">Z[1]") + .moveTo(0, 0) + .rect( + outer_len - hole_dist_from_short - hole_diameter * 2, + outer_width - hole_dist_from_long - hole_diameter * 3, + forConstruction=True, + ) + .vertices() + .cylinder(outer_thickness * 3, hole_diameter / 2, combine="cut") +) cq.exporters.export(result, "/home/deck/model_files/light_holder.step") diff --git a/oil_cap.py b/oil_cap.py index 897308d..8ca80d2 100644 --- a/oil_cap.py +++ b/oil_cap.py @@ -8,8 +8,8 @@ import itertools as it from cad_utilities.shapes import makeTriangle -cone = cq.Solid.makeCone(8/2, 1, 28) +cone = cq.Solid.makeCone(8 / 2, 1, 28) -result = Workplane().circle(8.3/2).extrude(30).cut(cone) +result = Workplane().circle(8.3 / 2).extrude(30).cut(cone) cq.exporters.export(result, "/home/deck/model_files/oil_cap.step") diff --git a/picture_frame.py b/picture_frame.py index 8e6ad07..e51037a 100644 --- a/picture_frame.py +++ b/picture_frame.py @@ -7,47 +7,55 @@ import functools as fnc import itertools as it picture_height = 178.3 -length = picture_height+5 +length = picture_height + 5 picture_length = 4.2 width = picture_length + 10 picture_width = 127 height = picture_width + 10 triangle_size = 25 -triangle_width = width+15 +triangle_width = width + 15 def makeTriangle(self, width, height, x_offset=0, y_offset=0): - return (self.moveTo(x_offset-(width), y_offset).makePolygon( - [ - (width, height, 0), (width*2, 0, 0), (width*2, width*2, 0), - ] - )) + return self.moveTo(x_offset - (width), y_offset).makePolygon( + [ + (width, height, 0), + (width * 2, 0, 0), + (width * 2, width * 2, 0), + ] + ) + def add_triangle(plane, width, height, offset): return plane.triangle(width, height, y_offset=offset) + Workplane.triangle = makeTriangle result = Workplane("front").box(length, width, height) -result = result.workplane().box(length-20, width, height-15, True, "cut") +result = result.workplane().box(length - 20, width, height - 15, True, "cut") -result = result.workplane().box(length-2, picture_length, picture_width+2, True, "cut") +result = result.workplane().box( + length - 2, picture_length, picture_width + 2, True, "cut" +) result = result.faces("Z[0]") .workplane() .move(-(turn_length / 3.5), 0) - .rect(32.2-(screw_head_diameter*2)+4, 37.9-(screw_head_diameter*2)+4, forConstruction=True) + .rect( + 32.2 - (screw_head_diameter * 2) + 4, + 37.9 - (screw_head_diameter * 2) + 4, + forConstruction=True, + ) .vertices() .cskHole(screw_diameter, screw_head_diameter, 83, depth=None) ) @@ -53,7 +57,11 @@ turn_result = ( turn_result.faces(">Z[0]") .workplane() .move((turn_length / 3.5), 0) - .rect(32.2-(screw_head_diameter*2)+4, 37.9-(screw_head_diameter*2)+4, forConstruction=True) + .rect( + 32.2 - (screw_head_diameter * 2) + 4, + 37.9 - (screw_head_diameter * 2) + 4, + forConstruction=True, + ) .vertices() .cskHole(screw_diameter, screw_head_diameter, 83, depth=None) ) @@ -62,14 +70,14 @@ turn_result = ( turn_result.faces(">Z[0]") .workplane(offset=5) .center(0, 0) - .cylinder(turn_shaft_height, turn_shaft_width/2) + .cylinder(turn_shaft_height, turn_shaft_width / 2) ) turn_result = ( turn_result.faces(">Z[1]") - .workplane(offset=(turn_shaft_height-(servo_height/2))) + .workplane(offset=(turn_shaft_height - (servo_height / 2))) .center(0, 0) - .cylinder(servo_height, servo_diameter/2, combine="cut") + .cylinder(servo_height, servo_diameter / 2, combine="cut") ) try: diff --git a/robot_steering.py b/robot_steering.py index 61e0db0..e0328ea 100644 --- a/robot_steering.py +++ b/robot_steering.py @@ -28,14 +28,12 @@ scaled_screw = screw.scale(1.01) screw_result = ( Workplane() - #.makePolygon(star(outerRadius=bottom_radius, innerRadius=13, n=8)) - #.extrude(8) + # .makePolygon(star(outerRadius=bottom_radius, innerRadius=13, n=8)) + # .extrude(8) .union(scaled_screw) ) -nut_result = nut_result.workplane(offset=3).threadedHole( - screw, 5.5, simple=simple -) +nut_result = nut_result.workplane(offset=3).threadedHole(screw, 5.5, simple=simple) box = Workplane().box(190, 100, 100) box = box.workplane(offset=0).move(10, 0).box(190, 90, 90, combine="cut") @@ -43,8 +41,8 @@ box = box.workplane(offset=0).move(50, 0).hole(7) try: show_object(scaled_screw) - #show_object(box) - #show_object(nut_result) + # show_object(box) + # show_object(nut_result) except NameError: pass diff --git a/solder_stand.py b/solder_stand.py index 33bdfcc..f607fd6 100644 --- a/solder_stand.py +++ b/solder_stand.py @@ -9,24 +9,41 @@ import itertools as it height = 30 width = 94 length = 130 -stand_height=23 +stand_height = 23 -socket_radius = 10.7/2 +socket_radius = 10.7 / 2 result = Workplane().box(length, width, height).edges("|Z").fillet(0.9) -result = result.workplane(offset=5).box(length-5, width-20, height, combine="cut") - -result = (result.workplane(offset=10).moveTo(0, -(width/2)+5) - .box(length=length, width=0.85, height=stand_height, combine="cut")) - -result = (result.workplane(offset=10).moveTo(0, (width/2)-5) - .box(length=length, width=0.85, height=stand_height, combine="cut")) - -result = result.faces(">X[3]").workplane().moveTo(-25,-5).sphere(socket_radius, combine="cut") -result = result.faces(">X[1]").box(12.5,5.5,7.5, combine="cut") - -result = result.faces(">X[0]").center(15, -10).text("Danger!", 8.5, -1.6, fontPath="/home/wes/fonts/StackyardPersonalUse-16Dj.ttf") +result = result.workplane(offset=5).box(length - 5, width - 20, height, combine="cut") + +result = ( + result.workplane(offset=10) + .moveTo(0, -(width / 2) + 5) + .box(length=length, width=0.85, height=stand_height, combine="cut") +) + +result = ( + result.workplane(offset=10) + .moveTo(0, (width / 2) - 5) + .box(length=length, width=0.85, height=stand_height, combine="cut") +) + +result = ( + result.faces(">X[3]") + .workplane() + .moveTo(-25, -5) + .sphere(socket_radius, combine="cut") +) +result = result.faces(">X[1]").box(12.5, 5.5, 7.5, combine="cut") + +result = ( + result.faces(">X[0]") + .center(15, -10) + .text( + "Danger!", 8.5, -1.6, fontPath="/home/wes/fonts/StackyardPersonalUse-16Dj.ttf" + ) +) cq.exporters.export(result, "/home/deck/model_files/solder_stand.step") diff --git a/tape_holder.py b/tape_holder.py index 0713f49..ee834bc 100644 --- a/tape_holder.py +++ b/tape_holder.py @@ -11,24 +11,26 @@ import itertools as it def makeTriangle(self, width, height, x_offset=0, y_offset=0): - return (self.move(x_offset, y_offset).makePolygon( - [ - (height/2, width*20, -width), (0, width, 0), (width, height, 0) - ] - )) + return self.move(x_offset, y_offset).makePolygon( + [(height / 2, width * 20, -width), (0, width, 0), (width, height, 0)] + ) + def add_triangle(plane, width, height, offset): return plane.triangle(width, height, y_offset=offset) + Workplane.triangle = makeTriangle # must be 17 mm wide # gap must be at least 4 mm holder_dim = (18, 30, 30) -holder_slot_dim = (holder_dim[0] + holder_dim[0]*0.65, - holder_dim[1]-holder_dim[1]*0.2, - holder_dim[1]-holder_dim[1]*0.865) # should be around 4mm +holder_slot_dim = ( + holder_dim[0] + holder_dim[0] * 0.65, + holder_dim[1] - holder_dim[1] * 0.2, + holder_dim[1] - holder_dim[1] * 0.865, +) # should be around 4mm pole_dim = (18, 10) lip_dim = (pole_dim[0], 15) @@ -38,20 +40,30 @@ print(holder_slot_dim) result = Workplane().box(*holder_dim) result = result.workplane().moveTo(0, -5).box(*holder_slot_dim, True, "cut") -result = (result.faces(">Z").workplane() - .moveTo(0, (holder_dim[0]) - 8) - .rect(*pole_dim).extrude(pole_length)) +result = ( + result.faces(">Z") + .workplane() + .moveTo(0, (holder_dim[0]) - 8) + .rect(*pole_dim) + .extrude(pole_length) +) support_width = 10 -result = result.faces(">Y[1]").workplane().triangle(support_width, - support_width, - -support_width/2, - -holder_dim[0]).extrude(15) +result = ( + result.faces(">Y[1]") + .workplane() + .triangle(support_width, support_width, -support_width / 2, -holder_dim[0]) + .extrude(15) +) -result = (result.faces(">Z[3]").center(0, pole_length-lip_dim[0]/4).workplane() - .moveTo(0, lip_dim[1]) - .rect(*lip_dim).extrude(pole_dim[0]/4)) +result = ( + result.faces(">Z[3]") + .center(0, pole_length - lip_dim[0] / 4) + .workplane() + .moveTo(0, lip_dim[1]) + .rect(*lip_dim) + .extrude(pole_dim[0] / 4) +) cq.exporters.export(result, "/home/deck/cad_files/tape_holder.step") - diff --git a/threaded_tool_holder.py b/threaded_tool_holder.py index 594941e..519e5c5 100644 --- a/threaded_tool_holder.py +++ b/threaded_tool_holder.py @@ -31,21 +31,21 @@ screw_result = ( .union(scaled_screw) ) -nut_result = nut_result.workplane(offset=9.3).threadedHole( - screw, 13, simple=simple -) +nut_result = nut_result.workplane(offset=9.3).threadedHole(screw, 13, simple=simple) box = Workplane().box(190, 100, 100) box = box.workplane(offset=0).move(10, 0).box(190, 90, 90, combine="cut") box = box.workplane(offset=0).move(50, 0).hole(7) try: - #show_object(screw_result) - #show_object(box) + # show_object(screw_result) + # show_object(box) show_object(nut_result) except NameError: pass -cq.exporters.export(screw_result, "/home/deck/model_files/threaded_tool_holder_screw.step") +cq.exporters.export( + screw_result, "/home/deck/model_files/threaded_tool_holder_screw.step" +) cq.exporters.export(nut_result, "/home/deck/model_files/threaded_tool_holder_nut.step") cq.exporters.export(box, "/home/deck/model_files/threaded_tool_holder_box.step") diff --git a/tool_holder.py b/tool_holder.py index e5fa994..5ecceb6 100644 --- a/tool_holder.py +++ b/tool_holder.py @@ -15,24 +15,29 @@ base_thickness = 7 height = 2.5 -result = (cq.Workplane().moveTo(-top_rect_len+2, 0) - .box(sides_width, bottom_rect_len, height) - .edges("|Z").fillet(1.25)) - - -result = (result.faces(">Z[0]").circle(1.5) +result = ( + cq.Workplane() + .moveTo(-top_rect_len + 2, 0) + .box(sides_width, bottom_rect_len, height) + .edges("|Z") + .fillet(1.25) +) + + +result = ( + result.faces(">Z[0]").circle(1.5).workplane().circle(sides_width - 1).loft().clean() +) + +result = result.faces(">Z[0]").box( + bottom_rect_len * 6, bottom_rect_len * 2, base_thickness +) +result = ( + result.faces(">Z") .workplane() - .circle(sides_width-1) - .loft() - .clean()) - -result = result.faces(">Z[0]").box(bottom_rect_len*6, bottom_rect_len*2, base_thickness) -result = (result - .faces(">Z").workplane() - .rect(bottom_rect_len*5, bottom_rect_len*1, forConstruction=True) + .rect(bottom_rect_len * 5, bottom_rect_len * 1, forConstruction=True) .vertices() - .cboreHole(4,8,7, depth=None)) - + .cboreHole(4, 8, 7, depth=None) +) cq.exporters.export(result, "/home/deck/cad_files/power_bar_holder.step") diff --git a/tool_holder_final.py b/tool_holder_final.py index 2317c4b..718094b 100644 --- a/tool_holder_final.py +++ b/tool_holder_final.py @@ -22,34 +22,52 @@ magnet_slot_offset = 10 second_slot_offset = -25 result = Workplane("front").box(length, width, height) -result = result.workplane().center(0, -bottom_thickness).workplane().box(length-wall_width, - width-wall_width, - height-wall_width, - True, - "cut") - -result = (result.faces(">Z").workplane(0, True) - .moveTo(0, first_magnet_position).rect(magnet_width, - magnet_height).cutBlind(magnet_thickness)) - -result = (result.faces(">Z").workplane(0, True) - .moveTo(0, magnet_slot_offset).rect(magnet_width, - magnet_height).cutBlind(magnet_thickness) - .faces(">Z") - .moveTo(0, magnet_slot_offset) - .rect(magnet_width, magnet_height).extrude(2)) - -result = (result.faces(">Z").workplane(0, True) - .moveTo(0, second_magnet_position).rect(magnet_width, - magnet_height).cutBlind(magnet_thickness)) - -result = (result.faces(">Z").workplane(0, True) - .moveTo(0, second_magnet_position+second_slot_offset).rect(magnet_width, - magnet_height).cutBlind(magnet_thickness) - .faces(">Z") - .moveTo(0, second_magnet_position+second_slot_offset) - .rect(magnet_width, magnet_height).extrude(2)) +result = ( + result.workplane() + .center(0, -bottom_thickness) + .workplane() + .box(length - wall_width, width - wall_width, height - wall_width, True, "cut") +) +result = ( + result.faces(">Z") + .workplane(0, True) + .moveTo(0, first_magnet_position) + .rect(magnet_width, magnet_height) + .cutBlind(magnet_thickness) +) + +result = ( + result.faces(">Z") + .workplane(0, True) + .moveTo(0, magnet_slot_offset) + .rect(magnet_width, magnet_height) + .cutBlind(magnet_thickness) + .faces(">Z") + .moveTo(0, magnet_slot_offset) + .rect(magnet_width, magnet_height) + .extrude(2) +) + +result = ( + result.faces(">Z") + .workplane(0, True) + .moveTo(0, second_magnet_position) + .rect(magnet_width, magnet_height) + .cutBlind(magnet_thickness) +) + +result = ( + result.faces(">Z") + .workplane(0, True) + .moveTo(0, second_magnet_position + second_slot_offset) + .rect(magnet_width, magnet_height) + .cutBlind(magnet_thickness) + .faces(">Z") + .moveTo(0, second_magnet_position + second_slot_offset) + .rect(magnet_width, magnet_height) + .extrude(2) +) cq.exporters.export(result, "/home/deck/cad_files/tool_holder.step") diff --git a/utilities.py b/utilities.py index fed104b..b211352 100644 --- a/utilities.py +++ b/utilities.py @@ -6,11 +6,17 @@ import cadquery as cq import functools as fnc import itertools as it + def makeTriangle(self, width, height, x_offset=0, y_offset=0): - return (self.moveTo(x_offset-(width), y_offset).makePolygon( - [ - (0,0,0),(width,height,0), (width*2,0,0), - ] - ) - .cutBlind(30) - .clean()) + return ( + self.moveTo(x_offset - (width), y_offset) + .makePolygon( + [ + (0, 0, 0), + (width, height, 0), + (width * 2, 0, 0), + ] + ) + .cutBlind(30) + .clean() + ) diff --git a/watch_stand.py b/watch_stand.py new file mode 100644 index 0000000..db6cb71 --- /dev/null +++ b/watch_stand.py @@ -0,0 +1,49 @@ +from cadquery import exporters +from cq_warehouse.extensions import Workplane +from cq_warehouse.fastener import * +from cq_warehouse.thread import * +from cqmore.curve import archimedeanSpiral, circle +from cqmore.polygon import regularPolygon, star +from cqmore.polyhedron import polarZonohedra, Polyhedron, superellipsoid +from svg_path import addSvgPath +from svgpathtools import svg2paths +import cadquery as cq +import cqmore + +base_diameter = 90 +base_radius = base_diameter / 2 + +band_diameter = 40 +band_radius = band_diameter / 2 + +clock_diameter = 35 +clock_radius = clock_diameter / 2 + +winding_knob_dist = clock_radius +band_width = 18.13 + +first_circle_height = 105 # how tall the horizontal circle part will be + +Workplane = cqmore.extend(Workplane) +Workplane.addSvgPath = addSvgPath + +result = Workplane() + +result = result.cylinder(first_circle_height, band_radius) + +result = result.faces(">Z[0]").sphere(base_radius) +result = result.workplane(offset=base_radius).box( + base_diameter, base_radius * 2, base_radius * 2, combine="cut" +) + +result = ( + result.workplane(offset=base_radius - 15) + .rect(base_radius, base_radius, forConstruction=True) + .vertices() + .cylinder(5, 5, combine="cut") +) + +try: + show_object(result) +except NameError: + pass diff --git a/webcam_stand.py b/webcam_stand.py index 08227f5..5a1bcd2 100644 --- a/webcam_stand.py +++ b/webcam_stand.py @@ -12,7 +12,11 @@ import cqmore Workplane = cqmore.extend(Workplane) -result = Workplane().makePolygon(regularPolygon(nSides=3, radius=35, thetaStart=0, thetaEnd=360)).extrude(50) +result = ( + Workplane() + .makePolygon(regularPolygon(nSides=3, radius=35, thetaStart=0, thetaEnd=360)) + .extrude(50) +) try: show_object(result) diff --git a/xmas_coaster.py b/xmas_coaster.py index 65815d1..2adfeb7 100755 --- a/xmas_coaster.py +++ b/xmas_coaster.py @@ -9,85 +9,88 @@ from cad_utilities.shapes import makeTriangle coaster_radius = 50 + def add_triangle(plane, width, height, offset): return plane.triangle(width, height, y_offset=offset) + def addXmas(self, offsets): xmas_tree_offset = -25 xmas_tree_height = 8 xmas_tree_width = 6 w_off, h_off, y_off = offsets - return self.triangle(xmas_tree_width+(choice([-1,1])*w_off), - xmas_tree_height+(choice([-1,1])*h_off), - y_offset=-(xmas_tree_offset+(y_off))) + return self.triangle( + xmas_tree_width + (choice([-1, 1]) * w_off), + xmas_tree_height + (choice([-1, 1]) * h_off), + y_offset=-(xmas_tree_offset + (y_off)), + ) def makeXmasTree(self): - xmas_tree_offset = -25 - xmas_tree_height = 8 - xmas_tree_width = 6 - - offsets = [(0,0,0)] + [tuple(randint(1, 5) for _ in range(4)) for _ in range(3)] - print(offsets) - - offsets_added = list(it.accumulate(offsets, lambda t1, t2: list(a+b for a,b in zip(t1, t2)))) - - last_y = offsets_added[-1][2] - - #offsets = [(0,0,0), (3,2,6), (4,11,13), (4,13,16)] - - tree = fnc.reduce(addXmas, offsets_added, self.center(0,0)) - - return (tree - .moveTo(0, -(xmas_tree_offset+last_y)) - .rect(2,5) - .cutThruAll()) - + xmas_tree_offset = -25 + xmas_tree_height = 8 + xmas_tree_width = 6 + + offsets = [(0, 0, 0)] + [tuple(randint(1, 5) for _ in range(4)) for _ in range(3)] + print(offsets) + + offsets_added = list( + it.accumulate(offsets, lambda t1, t2: list(a + b for a, b in zip(t1, t2))) + ) + + last_y = offsets_added[-1][2] + + # offsets = [(0,0,0), (3,2,6), (4,11,13), (4,13,16)] + + tree = fnc.reduce(addXmas, offsets_added, self.center(0, 0)) + + return tree.moveTo(0, -(xmas_tree_offset + last_y)).rect(2, 5).cutThruAll() + + Workplane.triangle = makeTriangle Workplane.xmasTree = makeXmasTree -polygon = (Workplane() - .makePolygon( - regularPolygon( - nSides = 16, - radius = coaster_radius, - thetaStart = 0, - thetaEnd = 360 - ) - ) - .extrude(7, clean=True, combine=True, taper=15) - .xmasTree() - ) - -result = (polygon.workplane() - .text("Wes", - 10, 40, - clean=True, - combine="cut", - fontPath="/home/wes/fonts/TiltNeon-Regular-VariableFont_XROT,YROT.ttf") - ) - - -result = (result.faces("Z").workplane() - .makePolygon( - regularPolygon( - nSides = 10, - radius = coaster_radius-5, - thetaStart = 0, - thetaEnd = 360 - ), - forConstruction=True - ) - .vertices() - .circle(2) - .extrude(5)) +polygon = ( + Workplane() + .makePolygon( + regularPolygon(nSides=16, radius=coaster_radius, thetaStart=0, thetaEnd=360) + ) + .extrude(7, clean=True, combine=True, taper=15) + .xmasTree() +) -cq.exporters.export(result, "/home/deck/cad_files/coaster.step") +result = polygon.workplane().text( + "Wes", + 10, + 40, + clean=True, + combine="cut", + fontPath="/home/wes/fonts/TiltNeon-Regular-VariableFont_XROT,YROT.ttf", +) + +result = ( + result.faces("Z") + .workplane() + .makePolygon( + regularPolygon( + nSides=10, radius=coaster_radius - 5, thetaStart=0, thetaEnd=360 + ), + forConstruction=True, + ) + .vertices() + .circle(2) + .extrude(5) +) + +cq.exporters.export(result, "/home/deck/cad_files/coaster.step")