diff --git a/Makefile b/Makefile index ab5d384..c3291df 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,6 @@ blend: $(BLENDER) blender/case_back.blend --background --python scripts/export_blender.py $(BLENDER) blender/trigger_R2.blend --background --python scripts/export_blender.py $(BLENDER) blender/trigger_R4.blend --background --python scripts/export_blender.py - $(BLENDER) blender/anchor.blend --background --python scripts/export_blender.py $(BLENDER) blender/dhat.blend --background --python scripts/export_blender.py $(BLENDER) blender/thumbstick.blend --background --python scripts/export_blender.py $(BLENDER) blender/button_home.blend --background --python scripts/export_blender.py diff --git a/build123d/anchor.py b/build123d/anchor.py new file mode 100644 index 0000000..66fcb56 --- /dev/null +++ b/build123d/anchor.py @@ -0,0 +1,107 @@ +from build123d import ( + BuildPart, BuildSketch, BuildLine, Box, Plane, Polyline, Rectangle, Location, Locations, + Axis, Rot, Mode, Align, Until, Cylinder, RegularPolygon, + mirror, make_face, edges, extrude, fillet, chamfer, split, faces, add, loft) + + +# top +TOP_WIDTH = 8 +TOP_DEPTH = 8 +TOP_HEIGHT = 8.3 +TOP_PTS = ((0,4), + (11, 4), + (TOP_DEPTH, TOP_HEIGHT), + (0, TOP_HEIGHT), + (0, 4)) +CHAMFER = 1 + +NUT_THICKNESS = 2.3 # should be 1.75 according to https://www.engineersedge.com/hardware/standard_metric_hex_nuts_13728.htm +NUT_WIDTH = 5 # across flats for M2.5 x 0.45 +NUT_TOLERANCE = +0.181 + +BOLT_HOLE_RADIUS = 1.3 + +# bottom +BOTTOM_WIDTH = 7 +BOTTOM_HEIGHT = 4 +BOTTOM_PTS = ((6, 0), + (15, 0), + (11, BOTTOM_HEIGHT), + (6, BOTTOM_HEIGHT), + (6, 0)) + +BOTTOM_CUTOUT_WIDTH = 3 +BOTTOM_CUTOUT_PTS = ((6, 0), + (10, 0), + (6, 4), + (6, 0)) + +FDM_BRIDGE_THICKNESS = 0.2 # only for FDM printing, otherwise set to 0.0 + + +with BuildPart() as anchor: + #Top + with BuildSketch(Plane.YZ): + with BuildLine(): + Polyline(TOP_PTS) + make_face() + extrude(amount=TOP_WIDTH) + + edge_list = edges().filter_by(Axis.Z) + chamfer(edge_list, CHAMFER) + + # Remove cutout for nut + location = Location((TOP_WIDTH / 2, # align center + TOP_DEPTH / 2, # align center + TOP_HEIGHT - NUT_THICKNESS)) + with BuildSketch(location): + RegularPolygon((NUT_WIDTH + NUT_TOLERANCE) / 2, 6, major_radius=False) + extrude(amount=NUT_THICKNESS, mode=Mode.SUBTRACT) + + # Remove cutout for bolt + location = Location((TOP_WIDTH / 2, # align center + TOP_DEPTH / 2, # align center + (TOP_HEIGHT + BOTTOM_HEIGHT) / 2)) + with Locations(location): + Cylinder(BOLT_HOLE_RADIUS, TOP_HEIGHT - BOTTOM_HEIGHT, mode=Mode.SUBTRACT) + + # Additional cutout to generate bridge for FDP printing + if FDM_BRIDGE_THICKNESS > 0: + location = Location((TOP_WIDTH / 2, # align center + TOP_DEPTH / 2, # align center + (TOP_HEIGHT + BOTTOM_HEIGHT) / 2 - FDM_BRIDGE_THICKNESS)) + with Locations(location): + Box(BOLT_HOLE_RADIUS * 2, + NUT_WIDTH + NUT_TOLERANCE, + FDM_BRIDGE_THICKNESS, + mode=Mode.SUBTRACT) + + + # Bottom + plane = Plane.YZ.offset((TOP_WIDTH - BOTTOM_WIDTH) / 2) + with BuildSketch(plane): + with BuildLine(): + Polyline(BOTTOM_PTS) + make_face() + extrude(amount=BOTTOM_WIDTH) + + with BuildPart(mode=Mode.SUBTRACT): + plane = Plane.YZ.offset(TOP_WIDTH - BOTTOM_WIDTH + BOTTOM_CUTOUT_WIDTH / 2) + with BuildSketch(plane): + with BuildLine(): + Polyline(BOTTOM_CUTOUT_PTS) + make_face() + extrude(amount=BOTTOM_CUTOUT_WIDTH) + + + + +# __main__ => show in VSCode +# temp => show in CQEditor +if __name__ in ['__main__', 'temp']: + if __name__ == '__main__': + from ocp_vscode import show_object + + show_object(anchor) + + print(f"Volume: {anchor.part.volume}") diff --git a/build123d/wheel.py b/build123d/wheel.py index 7d39d17..9ffda69 100644 --- a/build123d/wheel.py +++ b/build123d/wheel.py @@ -14,7 +14,7 @@ # Core CORE_RADIUS = 8 -CORE_TOLERANCE = 0.1 +CORE_TOLERANCE = 0.12 RIGHT_PADDING_LEN = 1.8 RIGHT_PADDING_RADIUS = 2 HEX_DIAMETER = 2.05 # 2 millimeter + extra for better fit. diff --git a/scripts/export_b123d.py b/scripts/export_b123d.py index f4606c1..fcacaeb 100644 --- a/scripts/export_b123d.py +++ b/scripts/export_b123d.py @@ -8,6 +8,7 @@ from button_select import button_select from button_dpad import button_dpad from cover import cover +from anchor import anchor from button_abxy import button_abxy STL_DIR = 'stl/' @@ -33,3 +34,6 @@ def export(obj, filename): # Battery Cover. export(cover.part, 'secondary_015mm_cover') + +# Anchor. +export(anchor.part, 'any_015mm_anchors_2x') diff --git a/scripts/export_blender.py b/scripts/export_blender.py index 441b8b8..0f8ec73 100644 --- a/scripts/export_blender.py +++ b/scripts/export_blender.py @@ -132,7 +132,6 @@ def export(self): Entry('Home', 'secondary_007mm_home', rotate=True), Entry('Thumbstick', 'secondary_007mm_thumbstick', tolerance=True), Entry('Hexagon', 'conductive_015mm_hexagon', '-Z', tolerance=True), - Entry('Anchor', 'any_015mm_anchors_2x', '-Z', split=True), Entry('Soldering helper', 'any_020mm_solderstand', '-Z', merge=True), ]