Skip to content

Instantly share code, notes, and snippets.

@al177
Created December 13, 2022 03:16
Show Gist options
  • Save al177/33748e70e499a88de552a0b88e5f2453 to your computer and use it in GitHub Desktop.
Save al177/33748e70e499a88de552a0b88e5f2453 to your computer and use it in GitHub Desktop.
Arch laptop stand SCAD
// length of the slot for each laptop
slot_width = 220;
// how high the laptop slot is from the desk
slot_lift = 10;
// height of the slot support from the edge of the laptop
slot_height = 80;
// thickness of the slot support
slot_thickness = 15;
/* section widths in the format [section_start, section_end, slot, chamfer] where:
section_start is the y distance for the start of the section
section_end is the y distance for the end of the section
slot=true if a slot is to be cut in the section
chamfer=1 to chamfer in +y, 0 for no chamfer, and -1 to chamfer in -y
*/
widths=[[0, 20, false, 1 ],
[20, 30, false, 0 ],
[30, 50, true, 0 ],
[50, 60, false, 0 ],
[60, 80, true, 0 ],
[80, 90, false, 0 ],
[90, 110 , false, -1 ]];
// end support width
end_width = 20;
// Find the radius for a circle that has an arc with a length 2w and perpendicular to the chord of h
function arc_rad_for_wh(w, h) = (w ^ 2 / (8 * h)) + h / 2;
module arch( slot_height,
slot_lift,
slot_width,
depth,
slot_thickness,
slot_cut,
chamfer) {
radius = arc_rad_for_wh(slot_width, slot_height + slot_lift);
chamfer_radius = arc_rad_for_wh((slot_height + slot_lift) * 2, depth);
$fn=128;
difference() {
translate([0, 0, -(radius - slot_height - slot_lift) ]) rotate([-90, 0, 0]) difference() {
cylinder(r=radius, h=depth);
translate([0, 0, -0.5])
cylinder(r=radius-slot_thickness, h=depth + 1);
}
translate([-radius - 0.5, -0.1, -((radius * 2) + 1)])
cube([(radius * 2) + 1, depth + 0.2, (radius * 2) + 1]);
if(slot_cut)
translate([-radius - 0.5, -0.1, slot_lift])
cube([(radius * 2) + 1, depth + 0.2, (radius * 2) + 1]);
if(chamfer != 0)
translate( [-radius - 0.5,
(chamfer > 0) ? -chamfer_radius + depth : chamfer_radius,
slot_lift + slot_height])
rotate([0, 90, 0])
cylinder(r=chamfer_radius, h=radius * 2 + 1);
}
}
union() {
for(slot = widths) {
translate([0, slot[0], 0])
arch( slot_height,
slot_lift,
slot_width,
slot[1] - slot[0],
slot_thickness,
slot[2],
slot[3] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment