Wednesday, May 6, 2026

building inside a case

refactored my case code to be generated by a solid that most things should fit inside, which is parametric in the "wall size" so i can generate the outer solid, the inner solid, and an inner solid with some clearance so parts should fit without trouble. the case then simply becomes outer - inner, plus holes for buttons and keys. this allows me to build cross beams a bit more readily, like the keyboard back bar here:
side bar: it looks like the keyboard back bar lays on the shoulder buttons, but there will be another crossbeam in between to avoid the shoulder buttons infringing on the keys' ability to bend, see video below.

the idea is to share as much code between building parts individually and modeling how they fit together, so i have a get_keyboard_pos() function which is used as the first parameter here, and build_case_clearance_solid() is memoized so it only needs to be calculated once. the keyboard position isn't needed when printing so it gets added and subtracted in this method, but not before intersecting with the case's inner clearance.
  def fit_in_case(where, part):
    return where.inverse() * (
        build_case_clearance_solid().intersect(
            where * part
        )
    )
and here is the result with the crossbar.

No comments:

Post a Comment