Skip to content

Commit

Permalink
Simplify manuform plate generation with more 2D ops
Browse files Browse the repository at this point in the history
Bottom plate generation in manuform.clj relied on several hacky 3D
operations (micro-translations before projection operations and
extruded screw hole shapes). This is replaced with 2D operations
followed by a single linear_extrude. This commit also fixes the
non-aligning bottom plate mentioned in ibnuda#112.
  • Loading branch information
mbugert committed May 18, 2022
1 parent cd1ad5f commit dea4f21
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
11 changes: 3 additions & 8 deletions src/dactyl_keyboard/common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,10 @@
(screw-insert-shape (+ screw-insert-bottom-radius screw-insert-wall-thickness)
(+ screw-insert-top-radius screw-insert-wall-thickness)
(+ screw-insert-height (- screw-insert-wall-thickness 0.1))))
(defn screw-insert-hole-plate
"For the bottom plate of the case: creates the shape of a through-hole that
fits an M3 screw"
(defn screw-hole
"For the bottom plate of the case: creates a 2D shape of an M3 screw hole."
[c]
(let [m3-through-hole-radius 1.7
max-height 350]
(screw-insert-shape m3-through-hole-radius
m3-through-hole-radius
max-height)))
(with-fn 20 (circle 1.7)))

(defn screw-placement-common
"Model-independent utility for positioning screw inserts based on their
Expand Down
16 changes: 10 additions & 6 deletions src/dactyl_keyboard/lightcycle.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1100,12 +1100,16 @@
(mirror [-1 0 0] (dactyl-top-right c)))

(defn dactyl-plate-right [c]
(let [use-screw-inserts? (get c :configuration-use-screw-inserts?)]
(cut
(translate [0 0 -0.1]
(difference (union (new-case c)
(if use-screw-inserts? (screw-placement c (screw-insert-wall c)) ()))
(if use-screw-inserts? (translate [0 0 -10] (screw-placement c (screw-insert-hole-plate c))) ()))))))
(let [use-screw-inserts? (get c :configuration-use-screw-inserts?)
screw-walls (if use-screw-inserts?
(screw-placement c (screw-insert-wall c))
())
screw-holes (if use-screw-inserts?
(screw-placement c (screw-hole c))
())]
(difference (cut (translate [0 0 -0.1] (union (new-case c)
screw-walls)
screw-holes)))))

(defn dactyl-plate-left [c]
(mirror [-1 0 0] (dactyl-plate-right c)))
Expand Down
24 changes: 12 additions & 12 deletions src/dactyl_keyboard/manuform.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1621,20 +1621,20 @@

(defn plate-right [c]
(let [use-screw-inserts? (get c :configuration-use-screw-inserts?)
screw-outers (if use-screw-inserts?
screw-walls (if use-screw-inserts?
(screw-placement c (screw-insert-wall c))
())
screw-inners (if use-screw-inserts?
(translate [0 0 -2] (screw-placement c (screw-insert-hole-plate c)))
screw-holes (if use-screw-inserts?
(screw-placement c (screw-hole c))
())
bot (cut (translate [0 0 -0.1] (union (case-walls c) screw-outers)))
inner-thing (difference (translate [0 0 -0.1] (project (union (extrude-linear {:height 5
:scale 0.1
:center true} bot)
(cube 50 50 5))))
screw-inners)]
(difference (extrude-linear {:height 3} inner-thing)
screw-inners)))
plate-perimeter (union (project screw-walls) (cut (case-walls c)))
; There is no operation for filling convex 2D shapes. Instead, linear
; extrude the 2D shape into a 3D cone, then project that again.
plate-filled (project (extrude-linear {:scale 0.0
:height 5
:center true} plate-perimeter))]
(extrude-linear {:height 3}
(difference plate-filled screw-holes))))

(defn plate-left [c]
(mirror [-1 0 0] (plate-right c)))
Expand Down Expand Up @@ -1699,7 +1699,7 @@
teensy-holder
; rj9-holder
screw-insert-wall)
(translate [0 0 -10] screw-insert-hole-plate))))))
(translate [0 0 -10] screw-hole))))))

#_(spit "things/left.scad"
(write-scad (mirror [-1 0 0] model-right)))
Expand Down

0 comments on commit dea4f21

Please sign in to comment.