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 Workplane = cqmore.extend(Workplane) Workplane.addSvgPath = addSvgPath # wk_paths, wk_attributes = svg2paths( # "/home/deck/cad_files/svgs/wk_edited.svg" # ) inner_radius = 5 outer_radius = 7 thickness = 3.5 rivet_inner_radius = 2 rivet_outer_radius = 3.5 rivet_thickness = 3 belt_width = 39 loop_thickness = 1.83 loop_side_thickness = 5 loop_height = 11.5 + loop_thickness loop_width = 25 loop_length = belt_width + loop_side_thickness 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).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) 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) ) 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 = 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) ) loop_bottom = loop_bottom.cut(slide_bottom_cut_left) loop_bottom = loop_bottom.cut(slide_bottom_cut_right) loop_bottom = loop_bottom.cut(slide_top_cut_left) loop_bottom = loop_bottom.cut(slide_top_cut_right) loop_top = loop_top.union(slide_bottom_union_left) 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) ) cq.exporters.export(rivet, "/home/deck/model_files/rivet_inner.step") cq.exporters.export(rivet_outer, "/home/deck/model_files/rivet_outer.step") 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) except NameError: pass