from cadquery import Workplane as WP from pallet import Pallet from gear import gear GEARS = False P = Pallet() od, id, l, fw, v = 30, 3, 20, 4, 5 d1, d2 = 5, 5 mod, teeth, bore, width, helixAngle = 2, 15, 2, l, 0 n = 31 / 2 outline = [(-21, -21), (-21, 21), (42, 21), (42, -21)] box = WP("YZ").polyline(outline).close().extrude(6) box = box.cut(WP("YZ").circle(22.3/2).pushPoints([(n,n),(-n,n),(n,-n),(-n,-n)])\ .circle(3.5/2).extrude(6)).faces(">X").edges("%circle").chamfer(2.5) box = box.union( WP("YZ").moveTo(od, 0).circle( 9.8 / 2).extrude(16).faces(">X").edges().chamfer(1)) box = box.faces(">Y").edges("|X").fillet(5) box = box.faces("<Y").edges("|X").fillet(5) cq.exporters.export(box.rotate((0, 0, 0), (0, 1, 0), -90), "box.stl") cq.exporters.export(box.rotate((0, 0, 0), (0, 1, 0), -90), "box.step") show_object(box)
verbose = False d1, pcd, pin, pitch, t = 20, 15, 3, 30, -3 #calculate link lenght at limit of design travel -45 degrees | (-pi/4) radians y = pcd / 2 * cos(-pi / 4) linkLength = ((y * 2)**2 + pitch**2)**0.5 log("*" * 80) N = 20 for n in range(N): theta = (n - N / 2) * pi / (N * 2) x1, y1 = pcd / 2 * sin(theta), pcd / 2 * cos(theta) linkLength = ((y1 * 2)**2 + pitch**2)**0.5 lv = ((x1 - pitch)**2 + (y1)**2)**0.5 wheel1 = WP().circle(d1 / 2).moveTo(x1, y1).circle(pin / 2).extrude(t) #wheel1 = wheel1.cut(WP().moveTo(-d1/2,0).rect(4,d1).extrude(t).rotate()) #rearange Cosine rule to get angle between lv and linklenght CosA = (b² + c² - a²)/2bc gamma = atan(y1 / abs(x1 - pitch)) + acos( (linkLength**2 + lv**2 - (pcd / 2)**2) / (2 * linkLength * lv)) if verbose: log(f"x1:{round(x1,3)} y1:{round(y1,3)} lenght:{abs(x1-pitch)/y1} gamma:{gamma}" ) #log(gamma) #x2,y2 are relative to wheel 2 center x2, y2 = linkLength * cos( gamma) + x1 - pitch, linkLength * -sin(gamma) + y1 wheel2 = WP().circle(d1 / 2).moveTo(x2, y2).circle(
from cadquery import Workplane as WP import cadquery as cq from math import cos, sin, pi h, w, l, wall = 40, 60, 100, 3 laserS = 33.3 railP, railD = 50, 6.5 motorBossD, motorBossL, motorMountP = 12.5, 16, 35 caridgeH, caridgeL = 30, 40 plateT = 8 plateW, plateH = 81, 100 motorD = WP().circle(26 / 2) motor = WP().pushPoints([(motorMountP / 2, 0), (-motorMountP / 2, 0)]).circle(4.3 / 2) laser = WP() caridge = WP().rect(w, caridgeH).extrude(caridgeL) caridge = caridge.cut(WP().pushPoints([(railP / 2, 0), (-railP / 2, 0) ]).circle(railD / 2).extrude(h)) caridge = caridge.cut(WP().rect( railP - wall * 2 - railD, caridgeH - wall * 2).extrude( (caridgeL - 5.6) / 2).edges("|Z").fillet(wall)) caridge = caridge.cut(WP().workplane(offset=caridgeL).rect( railP - wall * 2 - railD, caridgeH - wall * 2).extrude( -(caridgeL - 5.6) / 2).edges("|Z").fillet(wall)) caridge = caridge.cut(WP().circle(2.5 / 2).extrude(caridgeL)) caridge = caridge.union(WP().moveTo(0, laserS / 2 + caridgeH / 2).rect( laserS, laserS).rect(laserS + wall * 2, laserS + wall * 2).extrude(caridgeL)) caridge = caridge.faces("<X or >X").edges("|Z").chamfer(8)
from cadquery import Workplane as WP h, d = 35, 5 a = WP().rect(10, 10).circle( d / 2).extrude(35).faces(">Z").edges("%CIRCLE").fillet(0.5)
from cadquery import Workplane as WP import cadquery as cq pins, pitch, sq, h, w = 6, 2, 1, 6, 3.3 offset = (pitch * (pins - 1)) / 2 clearance = 0.2 a = WP().rect(pitch * pins + pitch / 2 - clerance, w).extrude(h - 1) #a = WP().moveTo() for p in range(pins): log(f"{offset + p*pitch} , {p}") a = a.cut(WP().moveTo(-offset + p * pitch, 0.6).rect(sq, sq).extrude(h)) cq.exporters.export(a, f"JST-PH_housing-{pins}_way.stl")
#compartmentalized tray from cadquery import Workplane as WP import cadquery as cq h, w, d, wall = 30, 170, 170, 2 rows, cols = 3, 3 fillet = wall cw = (w - wall * (cols + 1)) / cols rw = (w - wall * (rows + 1)) / rows cp = w / cols rp = d / rows a = WP().rect(w, d).extrude(h) for y in range(rows): Y = -float(rp * rows - rp) / 2 + y * rp for x in range(cols): X = -float(cp * cols - cp) / 2 + x * cp a = a.cut(WP().workplane(offset=wall).moveTo(X, Y).rect( cw, rw).extrude(h * 2)) a = a.edges("|Z").fillet(fillet) a = a.faces("<Z").edges().chamfer(wall) a = a.cut(WP().workplane(offset=h - wall / 2).rect( w, d).extrude(h).faces("<Z").edges().chamfer(wall)) cq.exporters.export( a, f"tray-({h}x{w}x{d})-rows({rows})-cols({cols})-wall({wall}).stl")
from cadquery import Workplane as WP import cadquery as cq h = 34 D = 30 r = 3 N = 3 flange = 2 c = 0.5 #thread_profile = cq.Workplane("XZ",origin=(R,0,0)).circle(r) #path = cq.Workplane("XY", obj=cq.Wire.makeHelix(R,N*R,R)) #res = thread_profile.sweep(path) a = WP().circle(D / 2).extrude(h) a = a.union(WP().circle(D / 2 + 2).extrude(flange).faces(">Z").edges().chamfer(flange - c)) a = a.union(WP().workplane( offset=h - flange).circle(D / 2 + 2).extrude(flange).faces("<Z").edges().chamfer(flange - c)) b = WP("YZ").center(D/2,h/2).polyline([(2,-4),(2,4),(-3,2.2),(-3,-2.2)]).close().extrude(20,both=True)\ .edges("|X").fillet(2).rotate((0,0,0),(0,1,0),10) for n in range(-12, 12): a = a.cut( b.rotate((0, 0, 0), (0, 0, 1), n * 30).translate((0, 0, n * 0.75))) w = (2.5**2 - 1.9**2)**0.5
import cadquery as cq from cadquery import Workplane as WP Dc, Ds, Kw, Kh = 40, 24.2, 8.2, 27.2 p = ((Ds / 2)**2 - (Kw / 2)**2)**0.5 keyway = WP().moveTo(-Kw/2,p).threePointArc((0,-Ds/2),(Kw/2,p))\ .lineTo(Kw/2,Kh-Ds/2).lineTo(-Kw/2,Kh-Ds/2).close().extrude(40)\ .translate((0,0,-30)) c = WP().circle(Dc / 2).extrude(5).cut(keyway) r = -120 txt = WP() for t in f"{Kw}x{Kh}x{Ds}": txt = txt.union(WP().text(t, 8, 5.5).translate( (0, -Dc / 2 + (Dc - Ds) / 4, 0)).rotate((0, 0, 0), (0, 0, 1), r)) r += 20 c = c.union(txt) show_object(c) cq.exporters.export(c, "0point2.stl")
#clares watch thingy from cadquery import Workplane as WP wD, oD, h, ledD = 40, 55, 25, 12 knobD = 7 strapW = 30 a = WP().circle(ledD / 2).circle(oD / 2).extrude(h) a = a.cut(WP().workplane(offset=h).rect(oD, strapW).extrude(-10)) a = a.cut(WP().workplane(offset=h).moveTo(0, oD / 2).rect(knobD, oD).extrude(-10)) a = a.cut(WP().workplane(offset=h).moveTo(12.5, -5.2).lineTo( 12.5, 5.2).close().offset2D(7.6 / 2).extrude(-18)) a = a.cut(WP().workplane(offset=h).moveTo(12.5, 0).lineTo( 12.5, -oD).close().offset2D(6.5 / 2).extrude(-17)) a = a.cut(WP().workplane(offset=h).lineTo(-oD, 12).lineTo( -oD, -12).close().offset2D(ledD / 2).extrude(-h)) a = a.cut(WP().workplane(offset=h).circle(40.5 / 2).extrude(-10)) a = a.edges("|Z").fillet(2) a = a.faces(">Z").edges().fillet(1) cq.exporters.export(a, "claresWatchStand.stl")
from cadquery import Workplane as WP import cadquery as cq pitch,d,h,w,n = 2.54, 2, 8, 4, 4 #pts = [(3.81,0),(1.27,0),(-1.27.0),(-3.81,0)] pts = [(pitch*(p- n/2+ 0.5),0) for p in range(n)] for p in pts: log(p) a = WP().rect((pitch+0.5)*n,w).extrude(h) a = a.cut(WP().pushPoints(pts).circle(2/2).extrude(h)) cq.exporters.export(a.rotate((0,0,0),(0,0,1),a),f"housing-{n}-way-{pitch}-pitch.stl")
from cadquery import Workplane as WP import cadquery as cq tag = WP().moveTo(0, 6).text("LIZZIE", 10, 1) tag = WP().moveTo(0, 6).text("HARGREAVES", 10, 1) tag = tag.union(WP().polygon(5, 50).extrude(-2)) #cq.exporters.export(a.rotate((0,0,0),(0,0,1),a),f"housing-{n}-way-{pitch}-pitch.stl")
from math import sin, cos, pi from cadquery import Workplane as WP import cadquery as cq AF = 12.2 r = 12.2 / cos(pi / 6) / 2 pts = [(r * cos(p * pi / 3), r * sin(p * pi / 3)) for p in range(6)] part = WP().polyline(pts).close().extrude(-4) pts = [(0, 0), (8, 0), (11.5, 11), (11.5, 22), (0, 22)] part = part.union( WP("XZ").polyline(pts).close().revolve(360, (0, 0, 0), (0, 1, 0))) r, af = 5.1 / 2, 4.5 y = af - r x = (r**2 - y**2)**0.5 part = part.cut(WP().workplane(offset=22).moveTo(x, y).threePointArc( (0, -r), (-x, y)).close().extrude(-15)) part = part.cut(WP().workplane(offset=-4).circle(3.3 / 2).extrude(12)) part = part.cut( WP("YZ").polyline([(AF / 2, -4), (AF / 2 + 4, -4), (AF / 2 + 4, 0) ]).close().revolve(360, (0, 0, 0), (0, 1, 0)))
from cadquery import Workplane as WP import cadquery as cq from math import sin, cos ,pi x1,y1 = 0, 73/2 x2,y2 = 4.4, -73/2 T = 20 AF = 5.7 r = AF/cos(pi/6)/2 n = 62/2*cos(pi/4) a = WP().circle(84/2).extrude(T) a = a.union(WP().pushPoints([(x1,y1),(x2,y2)]).circle(4.7/2).extrude(T+3)) a = a.faces(">Z").edges().fillet(0.5) a = a.union(WP().circle(51.7/2).extrude(-10).faces("<Z").edges().fillet(0.5)) clampHs = [(-1.8,10),(-1.8,-30)] a = a.cut(WP().pushPoints(clampHs).circle(3.3/2).extrude(T)) pts = [(r*sin(pi/6*p),r*cos(pi/6*p)) for p in (1,3,5,7,9,11)] for ch in clampHs: a = a.cut(WP().workplane(offset=-10).center(ch[0],ch[1]).polyline(pts).close().extrude(15)) a = a.cut(WP().pushPoints([(n,n),(n,-n),(-n,-n),(-n,n)]).circle(4.5/2).extrude(T)) a = a.cut(WP().workplane(offset=T).pushPoints([(n,n),(n,-n),(-n,-n),(-n,n)]).circle(8/2).extrude(-5)) cq.exporters.export(a,"plate.stl")
from cadquery import Workplane as WP import cadquery as cq from math import sin , cos, pi pts = [] np = 9 n = np*2 for p in range(n): if p %2: r= 100 else: r=30 pts.append((r*cos(2*pi/n*p),r*sin(2*pi/n*p))) a = WP().polyline(pts).close().extrude(5) for p in range(n): f = 10 if p %2: f = 4 a = a.edges("|Z").edges(cq.NearestToPointSelector(pts[p])).fillet(f)
import cadquery as cq from cadquery import Workplane as WP #from pallet import Pallet #from gear import gear line = [(30,0),(60,0),(60,50),(15,50),(0,15),(10,15)] a = WP().polyline(line).offset2D(2).extrude(10).faces(">X[-2]").edges("|Z").fillet(3)