#%% from build123d import * from ocp_vscode import * from bd_animation import AnimationGroup, clone, normalize_track import copy #%% text = Text("z", font_size=8.0, font_path="/usr/share/fonts/truetype/ebgaramond/EBGaramond12-Bold.ttf", font_style=FontStyle.BOLD,) show(text) set_defaults(reset_camera=Camera.KEEP, render_joints=True, helper_scale=8) #%% ri=3 r=4 with BuildPart() as drops: # Start with the plan of the key cap and extrude it with BuildSketch() as plan: RegularPolygon(ri,7,rotation=90) with BuildSketch(Plane.XY.offset(2)) as planb: Circle(r) loft() with BuildSketch(Plane.XY.offset(2)) as planc: Circle(r) extrude(amount=2) with BuildSketch() as txt: add(text) extrude(amount=0.25, mode=Mode.SUBTRACT) #chamfer(drops.edges(), length=0.05) mirror(about=Plane.XZ, mode=Mode.REPLACE) show(drops) # %% with BuildPart() as pezdrops: # Start with the plan of the key cap and extrude it with BuildSketch() as plan: RectangleRounded(15,8, 3) extrude(amount=5) with BuildSketch(Plane.XY) as planb: RectangleRounded(11,4, 0.5) with BuildSketch(Plane.XY.offset(2)) as planc: SlotCenterToCenter(7,2) loft(mode=Mode.SUBTRACT) fillet(pezdrops.faces().sort_by(Axis.Z)[0].edges(), radius=1) show(pezdrops) # %% with BuildPart() as mold: with Locations((0,0,1)): Box(108,108,3) with GridLocations(7+1, 8, 10, 10): add(copy.copy(drops), mode=Mode.SUBTRACT) show(mold) # %% with BuildPart() as pezmold: with Locations((0,0,2)): Box(116,112,7) with Locations((0,0,1.5)): Box(112,108,6,mode=Mode.SUBTRACT) with GridLocations(17, 10, 6, 10,align=(Align.CENTER, Align.CENTER)): add(copy.copy(pezdrops)) show(pezmold) # %% with BuildPart() as mold_for_mold: n = 10 pad = 5 dxy=10 w = (dxy)*n+2*pad wi = w-4 with Locations((0,0,1)): Box(w, w, 6) with Locations((0,0,1)): Box(wi,wi,3, mode=Mode.SUBTRACT) #with HexLocations(r+1,10,8): with GridLocations(dxy, dxy, n, n): add(copy.copy(drops), mode=Mode.ADD, rotation=(0,0,0)) with Locations((0,0,-2.5)): Box(wi,wi,4, mode=Mode.SUBTRACT) #add(mold, mode=Mode.SUBTRACT,rotation=180) show(mold_for_mold) # %% #export_step(mold_for_mold.part, "zdrops8mm_mold_for_mold2.step") # %% #export_step(pezmold.part, "pezmold.step") # %% nHoles = 10 vol_ml = 0.3 # millilitiers = 1/1000 * 10cm*10cm*10cm = 100mm*100mm*100mm/1000 = 1000mm³ vol = vol_ml * 1000 r = 4 # millimeters ri = 2 rrod=1 rodlen=100 tol = 0.05 A = 3.14*r*r t = vol/A # liter/meter wt = 1 l, w, h = (r+wt)*2, (r*2+wt)*(nHoles+0.5), t+4 with BuildPart() as pumpcylindercutout: with BuildSketch() as holes_sk: Circle(r) extrude(amount=t) with BuildSketch(pumpcylindercutout.faces().sort_by(Axis.Z)[0]) as rodhole_sk: Circle(rrod+tol) extrude(amount=10) chamfer(pumpcylindercutout.edges().sort_by(Axis.Z)[3],2) show(pumpcylindercutout) #%% with BuildPart() as oese: c=Cylinder(3,2,rotation=(0,90,0)) fillet(c.edges().filter_by(GeomType.CIRCLE), 0.9) Cylinder(1.5,2,rotation=(0,90,0), mode=Mode.SUBTRACT) show(oese) #%% with BuildPart() as pumpvalverod: rodlen=100 #Cylinder(3,4) #with Locations((0,0,rodlen/2-10)): # Cylinder(rrod,rodlen) with BuildSketch(Plane.YZ) as sk: with BuildLine() as outline: d=2 hn=1 l1=CenterArc((0,-rrod),rrod,270,90) l2=Line(l1@1,(rrod,hn)) l3=Line(l2@1,(rrod+d,hn+d)) l4=Line(l3@1,(rrod,hn+2*d)) l5=Line(l4@1,(rrod,rodlen)) l6=CenterArc((0,rodlen),rrod,0,90) l7=Line(l6@1,l1@0) make_face() revolve() fillet(pumpvalverod.edges().sort_by(Axis.Z)[5],0.5) with Locations((0,0,rodlen-3.5),(0,0,rodlen-11.5)): with Locations((-rrod,0,0),(rrod,0,0)): Box(rrod,7,4, mode=Mode.SUBTRACT) show(pumpvalverod) # %% with BuildPart() as pumpcylinder: rodlen=80 Cylinder(r, rodlen) with Locations((0,0,-rodlen/2+t/2)): Cylinder(ri, t,mode=Mode.SUBTRACT) #chamfer(pumpcylinder.edges()[4],1) with Locations((0,0,t/2)): Box(ri*2,r*2,rodlen-t,mode=Mode.SUBTRACT) with Locations((0,0,-rodlen/2+t+1)): Box(ri*2,r*3,r*3,rotation=(45,0,0), mode=Mode.SUBTRACT) Box(ri*2,r*3,r*3, mode=Mode.SUBTRACT) with Locations((0,-ri-1,-2),(0,ri+1,-2)): Box(r*2,ri+2,rodlen-t-4,mode=Mode.SUBTRACT) #s=pumpcylinder.edges().group_by(Axis.Z)[2] #filter_by(GeomType.CIRCLE,reverse=True)#.filter_by(Axis.X.is_parallel) #fillet( s[0:2],1) chamfer(pumpcylinder.edges().group_by(Axis.Z)[0][1],1) show(pumpcylinder) #%% with BuildPart() as pumpcylinderblock: Box(l,w,h) f = pumpcylinderblock.faces()[5].offset(-t) #with GridLocations() with Locations((0,0,h/2-t)): with GridLocations(0,r+wt+r,1,nHoles): add(pumpcylindercutout,mode=Mode.SUBTRACT) chamfer(pumpcylinderblock.edges().group_by(Axis.Z)[-1].filter_by(GeomType.CIRCLE), 0.4) RigidJoint("slide", joint_location=Location(Plane.XY)) show(pumpcylinderblock) #%% with BuildPart() as stand: ws = 120 wsx=60 with Locations((0,0,-h/2)): Box(wsx,ws,4) Box(wsx-4,ws-4,4,mode=Mode.SUBTRACT) Box(wsx,4,4) Box(4,ws,4) with Locations((0,0,-1)): Box(l+2,w+2,h+2) Box(l,w,h, mode=Mode.SUBTRACT) with BuildSketch(Plane.XY.offset(-(h+2)/2+3)): RectangleRounded(l-3,w-3,3) extrude(amount=-10, mode=Mode.SUBTRACT) with BuildPart() as standfoot: hs=50 ws=12 Box(ws,ws,hs) ds=2 with Locations((-ds,-ds,0)): Box(ws-ds,ws-ds,hs,mode=Mode.SUBTRACT) with Locations((0,0,hs/2-2)): Box(ws,4,4,mode=Mode.SUBTRACT) Box(4,ws,4,mode=Mode.SUBTRACT) #extrude(amount=4) #offset(amount=-1.9, openings=[stand.faces().sort_by(Axis.Z)[-1]]) show(standfoot) #%% with BuildPart() as pumpcylinderrods: with Locations((0,0,h/2-t-2-rrod)): with GridLocations(0,r+wt+r,1,nHoles): add(copy.copy(pumpvalverod)) with BuildPart() as pumpcylinders: with Locations((0,0,h/2-t+rodlen/2)): with GridLocations(0,r+wt+r,1,nHoles): add(copy.copy(pumpcylinder),rotation=(0,0,90)) LinearJoint("cylinders", axis=Axis.Z, linear_range=(-t, t)) pumpcylinderblock.part.joints["slide"].connect_to(pumpcylinders.joints["cylinders"]) show(pumpcylinderblock,stand,pumpcylinderrods,pumpcylinders,render_joints=True)#, pumpcylindercutout)# %% # %% pumpcylinder.edges().group_by(Axis.Z)[1] # %% with BuildPart() as hopper: with BuildSketch(Plane.XY.offset(h/2)) as down_sk: RectangleRounded(l,w,4) with BuildSketch(Plane.XY.offset(60)) as up_sk: with Locations((20,0)): RectangleRounded(l+50,w+50, 8) loft() offset(amount=-0.5, openings=[hopper.faces().sort_by(Axis.Z)[0],\ hopper.faces().sort_by(Axis.Z)[-1]]) #show(hopper) show(pumpcylinderblock,pumpcylinderrods,pumpcylinders,hopper,render_joints=True)#, pumpcylindercutout)# %% # %% show(hopper,hopper.faces().sort_by(Axis.Z)[-1]) # %% hopperblock = pumpcylinderblock.part + hopper.part show(hopperblock) # %% export_step(hopperblock, "machineparts/hopperblock.step") export_step(stand.part, "machineparts/stand.step") export_step(standfoot.part, "machineparts/standfoot.step") export_step(pumpvalverod.part, "machineparts/valverod.step") export_step(pumpcylinder.part, "machineparts/pumpcylinder.step") # %% with BuildPart() as idb_holder: Box(24,46,8) with Locations((0,0,1)): with GridLocations(7,7,3,6): Cylinder(2.3,6,mode=Mode.SUBTRACT) fillet(idb_holder.edges().filter_by(GeomType.CIRCLE), radius=1) fillet(idb_holder.edges().filter_by(Axis.Z), radius=5) fillet(idb_holder.edges().group_by(Axis.Z)[-1].filter_by(GeomType.LINE)[0], radius=1.5) show(idb_holder) # %% show(idb_holder, idb_holder.edges().group_by(Axis.Z)[-1].filter_by(GeomType.LINE)[0]) # %% export_step(idb_holder.part, "idb_holder.step") # %% def step_profile(stepfile="/home/hbrs/Downloads/tmp/I_slot_5_20x40.stp"): iprofile = import_step(stepfile) iface = iprofile.faces().sort_by(Axis.Z)[0] def buildfn(length=50): with BuildPart() as profile: with BuildSketch() as profile_sk: add(iface) extrude(amount=length) return Pos(0,13.3765,0)*Rot(0,0,90)*profile.part return buildfn iprofile=step_profile() # %% hp = 260 w = 240 w1 = w+40 w2 =hp+20 w3 = hp + 40 profiles= [ \ Pos(0,0,0)*Rot(0,0,90)*iprofile(hp), \ Pos(w1,0,0)*Rot(0,0,90)*iprofile(hp), \ Pos(0,w2,0)*Rot(0,0,90)*iprofile(hp), \ Pos(w1,w2,0)*Rot(0,0,90)*iprofile(hp), \ Pos(0,w2,0)*Rot(90,90,0)*iprofile(w), \ Pos(0,0,0)*Rot(90,90,0)*iprofile(w), \ Pos(-40,20,40)*Rot(-90,0,0)*iprofile(hp), \ Pos(hp,20,40)*Rot(-90,0,0)*iprofile(hp), \ Pos(0,0,w2)*Rot(-90,0,90)*iprofile(w3), \ Pos(w2,0,w2)*Rot(-90,0,90)*iprofile(w3), \ Pos(w2/2,0,60)*Rot(-90,0,90)*iprofile(w3), \ ] show(*profiles)#, hopperblock) # %% # %%