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 = 100 base_radius = base_diameter / 2 stand_diameter = 38 stand_radius = stand_diameter / 1.5 clock_diameter = 35 clock_radius = clock_diameter / 2 winding_knob_dist = clock_radius band_width = 21 band_diameter = 55 band_radius = band_diameter / 2 first_circle_height = 175 # how tall the horizontal circle part will be Workplane = cqmore.extend(Workplane) Workplane.addSvgPath = addSvgPath stand_base = Workplane("ZY") holder_part = Workplane("XY") simple = False screw = ButtonHeadScrew( size="M16-2", fastener_type="iso7380_1", length=20 * MM, simple=simple ) thread_scaled_screw = screw.scale(0.5) scaled_screw = screw.scale(1.00) small_scaled_screw = scaled_screw.scale(0.5) stand_base = stand_base.cylinder(first_circle_height, stand_radius) stand_base = ( stand_base.workplane(offset=-70) .move(0, 21) .box(20, 25, 20) .workplane(offset=-69) .transformed((90, 0, 0), (0, 0, 0)) .threadedHole(screw, 34, simple=simple, fit="Loose") ) stand_base = stand_base.faces(">X[0]").sphere(base_radius * 1.5) stand_base = stand_base.workplane(offset=base_radius * 2).box( base_diameter * 2, base_radius * 3, base_radius * 3, combine="cut" ) stand_base = ( stand_base.workplane(offset=base_radius - 5) .rect(base_radius * 1.5, base_radius * 1.5, forConstruction=True) .vertices() .cylinder(9, 6, combine="cut") ) holder_angle_offset = 67 clock_paths, clock_attributes = svg2paths("/home/deck/cad_files/svgs/clock.svg") svgs_to_render = [(clock_paths, (-50, -125, 46), "cut", "XY")] holder_part = ( holder_part.workplane(offset=2) .makePolygon( regularPolygon( nSides=12, radius=band_radius, thetaStart=holder_angle_offset, thetaEnd=360 + holder_angle_offset, ) ) .extrude(band_width) ) holder_part = holder_part.faces(">Z[0]").cylinder(5, 8).union(small_scaled_screw) if True: image_objects = [] for svg_paths, translate_offsets, combine, planes in svgs_to_render: image_objects.append( Workplane(planes) .center(0, 75) .addSvgPath(svg_paths[0]) .extrude(-2.0) .translate(translate_offsets) ) for image_object in image_objects: image_object = image_object.val().scale(0.5) if combine == "cut": holder_part = holder_part.cut(image_object, clean=False) if combine == "union": holder_part = holder_part.union(image_object, clean=False) cq.exporters.export(stand_base, "/home/deck/model_files/watch_stand_base.step") cq.exporters.export(scaled_screw, "/home/deck/model_files/watch_stand_screw.step") cq.exporters.export( small_scaled_screw, "/home/deck/model_files/watch_stand_screw_small.step" ) cq.exporters.export(holder_part, "/home/deck/model_files/watch_stand_holder.step") try: show_object(stand_base) # show_object(cut_polygon) # show_object(holder_part) except NameError: pass