#%% 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") # %%