diff --git a/planter.py b/planter.py index 8369848..e802b53 100644 --- a/planter.py +++ b/planter.py @@ -3,7 +3,7 @@ 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 +from cqmore.polyhedron import polarZonohedra, Polyhedron, superellipsoid from cq_warehouse.extensions import Workplane import functools as fnc import itertools as it @@ -13,77 +13,123 @@ import cqmore Workplane = cqmore.extend(Workplane) planter_height = 210 -planter_radius = 130 +planter_radius = 129 plate_offset = 47 plate_thickness = 3 zonohedra = polarZonohedra(8, 49) -outer_points = [[n*(planter_height/3.5) for n in vec] for vec in zonohedra.points] - +outer_points = [[n * (planter_height / 3.5) for n in vec] for vec in zonohedra.points] outer_faces = zonohedra.faces - outer_poly = Polyhedron(outer_points, outer_faces) result = Workplane().polyhedron(*outer_poly) holder_angle_offset = 20 -result = (result.workplane(offset=-38).makePolygon( - regularPolygon(nSides=4, - radius=planter_radius-40, - thetaStart=holder_angle_offset, - thetaEnd=360+holder_angle_offset), - forConstruction=True) - .vertices().cylinder(10, 7, combine="cut")) - -cone = cq.Solid.makeCone(planter_radius, 33, planter_height+95) +result = ( + result.workplane(offset=-38) + .makePolygon( + regularPolygon( + nSides=4, + radius=planter_radius - 40, + thetaStart=holder_angle_offset, + thetaEnd=360 + holder_angle_offset, + ), + forConstruction=True, + ) + .vertices() + .cylinder(10, 7, combine="cut") +) + +cone = cq.Solid.makeCone(planter_radius, 33, planter_height + 95) result = result.workplane().cut(cone) -result = result.workplane(offset=-40).cylinder(planter_height/1.45, planter_radius*0.58, combine="cut") -result = result.workplane(offset=-16).cylinder(planter_height/2.3, planter_radius/2.5, combine="cut") -result = result.workplane(offset=-5).cylinder(planter_height/2.3, planter_radius/1.85, combine="cut") +result = result.workplane(offset=-40).cylinder( + planter_height / 1.45, planter_radius * 0.58, combine="cut" +) +result = result.workplane(offset=-16).cylinder( + planter_height / 2.3, planter_radius / 2.5, combine="cut" +) +result = result.workplane(offset=-5).cylinder( + planter_height / 2.3, planter_radius / 1.85, combine="cut" +) + +result = ( + result.workplane(offset=40) + .makePolygon( + regularPolygon( + nSides=8, + radius=planter_radius / 2.2, + thetaStart=holder_angle_offset, + thetaEnd=360 + holder_angle_offset, + ) + ) + .extrude(planter_height / 15.5, combine="cut") +) + +circle_plate = Workplane().cylinder( + plate_thickness, planter_radius * 0.56 +) # enough to fit 0.58 + +# Split this out into a different part +circle_plate = ( + circle_plate.workplane(offset=plate_offset + plate_thickness) + .makePolygon( + star(outerRadius=planter_radius / 3, innerRadius=planter_radius / 4.9, n=8), + forConstruction=True, + ) + .vertices() + .cskHole(8, 8, 0.5, depth=None) +) -#result = result.workplane(offset=-10).makePolygon(regularPolygon(nSides=4, radius=planter_radius/2.8, thetaStart=holder_angle_offset, thetaEnd=360+holder_angle_offset)).extrude(planter_height/2.8, combine="cut") +simple = False -result = result.workplane(offset=40).makePolygon(regularPolygon(nSides=8, radius=planter_radius/2.2, thetaStart=holder_angle_offset, thetaEnd=360+holder_angle_offset)).extrude(planter_height/15.5, combine="cut") +screw = ButtonHeadScrew( + size="M16-2", fastener_type="iso7380_1", length=10 * MM, simple=simple +) +scaled_screw = screw.scale(0.90) -circle_plate = Workplane().cylinder(plate_thickness, planter_radius/2.2) +screw_result = Workplane().circle(20).extrude(10).union(scaled_screw) -# Split this out into a different part -circle_plate = (circle_plate.workplane(offset=plate_offset+plate_thickness) - .makePolygon( - star( - outerRadius=planter_radius/2.6, - innerRadius=planter_radius/4.9, - n=8), - forConstruction=True) - .vertices().cskHole(8, 8, 0.5, depth=None)) +result = result.workplane(offset=planter_height / 2).cylinder(80, 65, combine="cut") -simple = False +result = ( + result.workplane(offset=(planter_height / 2) - 27) + .makePolygon( + regularPolygon( + nSides=11, + radius=planter_radius / 1.85, + thetaStart=holder_angle_offset, + thetaEnd=360 + holder_angle_offset, + ) + ) + .extrude(10) +) -screw = ButtonHeadScrew(size="M16-2", fastener_type="iso7380_1", length=10 * MM, simple=simple) +result = result.workplane(offset=(planter_height / 2) - 15.8).threadedHole( + screw, 20, simple=simple, fit="Loose" +) -scaled_screw = screw.scale(0.92) +tapered_circle = ( + result.workplane(offset=planter_height / 3.0).circle(30).extrude(10, taper=42) +) +tapered_circle_inner = ( + result.workplane(offset=planter_height / 3.0).circle(20).extrude(10, taper=42) +) -screw_result = Workplane().circle(20).extrude(10).union(scaled_screw) +cut_tapered = Workplane().union(tapered_circle).cut(tapered_circle_inner) -result = result.workplane(offset=planter_height/2).cylinder(80, 65, combine="cut") -result = result.workplane(offset=(planter_height/2)-27).makePolygon(regularPolygon(nSides=11, - radius=planter_radius/1.85, - thetaStart=holder_angle_offset, - thetaEnd=360+holder_angle_offset)).extrude(10) -result = result.workplane(offset=(planter_height/2)-40).cylinder(80, 8.1, combine="cut") -result = result.workplane(offset=(planter_height/2)-15.6).threadedHole(screw, 20, simple=simple, fit="Loose") +result = result.union(cut_tapered) assembly = cq.Assembly() -assembly.add(screw_result, loc=cq.Location((0,0,0))) -assembly.add(result, loc=cq.Location((100,100,100))) -assembly.add(circle_plate, loc=cq.Location((1100,1100,1100))) +assembly.add(screw_result, loc=cq.Location((0, 0, 0))) +assembly.add(result, loc=cq.Location((100, 100, 100))) +assembly.add(circle_plate, loc=cq.Location((1100, 1100, 1100))) try: show_object(result)