mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
finalized porting examples
This commit is contained in:
parent
ae564754b7
commit
b1410a828e
14 changed files with 789 additions and 202 deletions
42
examples/key_cap_algebra.py
Normal file
42
examples/key_cap_algebra.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
from build123d import *
|
||||
|
||||
# Taper Extrude and Extrude to "next" while creating a Cherry MX key cap
|
||||
# See: https://www.cherrymx.de/en/dev.html
|
||||
|
||||
plan = Rectangle(18 * MM, 18 * MM)
|
||||
key_cap = extrude(plan, amount=10 * MM, taper=15)
|
||||
|
||||
# Create a dished top
|
||||
key_cap -= Location((0, -3 * MM, 47 * MM), (90, 0, 0)) * Sphere(40 * MM)
|
||||
|
||||
# Fillet all the edges except the bottom
|
||||
key_cap = fillet(
|
||||
*key_cap.edges().filter_by_position(Axis.Z, 0, 30 * MM, inclusive=(False, True)),
|
||||
radius=1 * MM,
|
||||
target=key_cap,
|
||||
)
|
||||
|
||||
# Hollow out the key by subtracting a scaled version
|
||||
key_cap -= scale(key_cap, by=(0.925, 0.925, 0.85))
|
||||
|
||||
|
||||
# Add supporting ribs while leaving room for switch activation
|
||||
ribs = Rectangle(17.5 * MM, 0.5 * MM)
|
||||
ribs += Rectangle(0.5 * MM, 17.5 * MM)
|
||||
ribs += Circle(radius=5.51 * MM / 2)
|
||||
|
||||
# Extrude the mount and ribs to the key cap underside
|
||||
key_cap += extrude(Pos(0, 0, 4 * MM) * ribs, until=Until.NEXT, target_object=key_cap)
|
||||
|
||||
|
||||
# Find the face on the bottom of the ribs to build onto
|
||||
rib_bottom = key_cap.faces().filter_by_position(Axis.Z, 4 * MM, 4 * MM)[0]
|
||||
|
||||
# Add the switch socket
|
||||
socket = Circle(radius=5.5 * MM / 2)
|
||||
socket -= Rectangle(4.1 * MM, 1.17 * MM)
|
||||
socket -= Rectangle(1.17 * MM, 4.1 * MM)
|
||||
key_cap += extrude(Plane(rib_bottom) * socket, amount=3.5 * MM)
|
||||
|
||||
if "show_object" in locals():
|
||||
show_object(key_cap, name="key cap", options={"alpha": 0.7})
|
||||
Loading…
Add table
Add a link
Reference in a new issue