Skip to content

Commit

Permalink
add reference(), as attachable() with invisible dummy base shape. Add…
Browse files Browse the repository at this point in the history
… , slightly expands the inside size to make sure parts are well seated into the box
  • Loading branch information
lijon committed Feb 11, 2024
1 parent 1a69f27 commit 30b248c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
37 changes: 34 additions & 3 deletions box.scad
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $box_cut_color = "#977";
$box_outside_color = "#ccc";
$box_inside_color = "#a99";
$box_preview_color = "#77f8";
$box_show_previews = true;
$box_inside_overlap = 0.0001;

function quant(val, q) = round(val/q)*q;

Expand All @@ -45,6 +45,37 @@ function vector_name(v) =
// return val unless it's a, then return b
function unless(val, a, b) = val == a ? b : val;

// convenience module to make an attachable without a base shape
module reference(
anchor=CENTER,spin=0,orient=UP,
size, size2, shift,
r,r1,r2, d,d1,d2, l,h,
vnf, path, region,
extent=true,
cp=[0,0,0],
offset=[0,0,0],
anchors=[],
two_d=false,
axis=UP,override,
geom
) {
attachable(
anchor,spin,orient,
size, size2, shift,
r,r1,r2, d,d1,d2, l,h,
vnf, path, region,
extent,
cp,
offset,
anchors,
two_d,
axis,override,
geom
) {
union() {} // invisible base shape
children();
}
}

/*
parent module for making box shells.
Expand All @@ -63,14 +94,14 @@ module _box_shell(size, splitpoint, walls, walls_outside, halves) {
$box_shell_halves = halves;
$box_walls = walls;
$box_walls_xyz = [for(i = [0:2:5]) walls[i]+walls[i+1]]; // left+right, back+front, top+bot
$box_inside_ofs = [for(i = [0:2:5]) walls[i]];
$box_inside_ofs = [for(i = [0:2:5]) walls[i]-$box_inside_overlap];

size = scalar_vec3(size);

sz = walls_outside ? (size + $box_walls_xyz) : size;

$box_size = sz; // outside size
$box_inside_size = sz - $box_walls_xyz;
$box_inside_size = sz - $box_walls_xyz + scalar_vec3($box_inside_overlap*2);

$box_splitpoint = splitpoint - $box_inside_ofs;

Expand Down
Binary file modified examples/BOT_esp_oled_sensor_box.stl
Binary file not shown.
Binary file modified examples/TOP_esp_oled_sensor_box.stl
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/esp_oled_sensor_box.scad
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ middle_cut = 31;
//cut_inspect(LEFT)
//cut_inspect(LEFT,ofs=-28)
//cut_inspect(LEFT,ofs=-middle_cut/2,s=150) cut_inspect(RIGHT,ofs=-middle_cut/2,s=150) // middle cutout
box_make(print=false,explode=0,hide_box=false)
box_make(print=true,explode=0.1,hide_box=false)
box_shell_base_lid(box_sz,rsides=4,rtop_inside=1,rbot_inside=1,rtop=1,wall_sides=1.6,base_height=4,rim_height=5)
{
M(pcb_pad,pcb_pad) position(FRONT+LEFT) d1mini(anchor=FRONT+LEFT);
Expand Down

0 comments on commit 30b248c

Please sign in to comment.