BOSL2 icon indicating copy to clipboard operation
BOSL2 copied to clipboard

Sparse shapes beyond wall

Open jdanders opened this issue 3 months ago • 10 comments

Is your feature request related to a problem? Please describe. I love the strength and efficiency of the sparse wall, but not everything I do is oriented as a wall. Usually I start my design using cuboids and then realize I am wasting too much material and convert them to sparse walls. It drives me crazy to get the orientation and parameters right in the conversion from

cuboid([10,20,30]);

to

sparse_wall(h=10, l=20, thick=30);

Usually the holes end up the wrong direction, then all my anchors and positions get messed up when I try to tweak orientation of the wall.

Describe the solution you'd like At this point, I'd like to see a sparse cuboid, but if it makes sense, this could be expanded to other 3d shapes. A sparse_cuboid takes the same parameters as a cuboid, but adds the cutouts of the sparse_wall and puts the cutouts in the right orientation.

Describe alternatives you've considered Here's my lame version of a sparse cuboid. It assumes the holes should align with the shortest dimension. A more elegant version might have a parameter that chooses hole orientation. I would love it if all the features of cuboids were available, like rounding.

Example Code

include <BOSL2/std.scad>
include <BOSL2/walls.scad>
module sparse_cuboid(size, maxang=30, strut=5, max_bridge=20, anchor=CENTER, spin=0, orient=UP) {
  if (size[0] <= size[1] && size[0] <= size[2]) // x skinny
    attachable(anchor=anchor, spin=spin, orient=orient, size=size) {
      sparse_wall(h=size[2], l=size[1], thick=size[0], maxang=maxang, strut=strut,
                  max_bridge=max_bridge);
      children();
    }
  else if (size[1] <= size[0] && size[1] <= size[2]) // y skinny
    attachable(anchor=anchor, spin=spin, orient=orient, size=size) {
      zrot(90) sparse_wall(h=size[2], l=size[0], thick=size[1], maxang=maxang, strut=strut,
                           max_bridge=max_bridge);
      children();
    }
  else if (size[2] <= size[0] && size[2] <= size[1]) // z skinny
    attachable(anchor=anchor, spin=spin, orient=orient, size=size) {
      xrot(90) zrot(90) sparse_wall(h=size[0], l=size[1], thick=size[2], maxang=maxang, strut=strut,
                           max_bridge=max_bridge);
      children();
    }
  else echo("Failed sparse cuboid");
}

Here's what three cuboids look like when converted to sparse_wall. image

Here's what I would like it to look like: image

sparse_cuboid([10,20,30], strut=1);
fwd(30) sparse_cuboid([30,20,10], strut=1);
fwd(60) sparse_cuboid([20,10,30], strut=1);

Yes, these are the same three shapes with different orientation, but I can never figure out how to fix the orientation without major side-effects.

jdanders avatar Apr 04 '24 21:04 jdanders