diff --git a/readme.md b/readme.md index 53fa5cd..affc873 100644 --- a/readme.md +++ b/readme.md @@ -5511,8 +5511,10 @@ a square cornered part fits in the hole then circles are placed in the corners m ### Modules | Module | Description | |:--- |:--- | -| ```dogbone_rectangle(size, r = cnc_bit_r, center = true, xy_center = true)``` | Rectangle with cylinders at the corners | -| ```dogbone_square(size, r = cnc_bit_r, center = true)``` | Square with circles at the corners | +| ```dogbone_rectangle(size, r = cnc_bit_r, center = true, xy_center = true, x_offset, y_offset)``` | Rectangle with cylinders at the corners | +| ```dogbone_rectangle_x(size, r = cnc_bit_r, center = true, xy_center = true)``` | Rectangle with cylinders at the corners, offset in the x direction | +| ```dogbone_rectangle_y(size, r = cnc_bit_r, center = true, xy_center = true)``` | Rectangle with cylinders at the corners, offset in the y direction | +| ```dogbone_square(size, r = cnc_bit_r, center = true, x_offset, y_offset)``` | Square with circles at the corners, with optional offsets | ![dogbones](tests/png/dogbones.png) diff --git a/tests/dogbones.scad b/tests/dogbones.scad index 09b5bd0..4fa862a 100644 --- a/tests/dogbones.scad +++ b/tests/dogbones.scad @@ -26,6 +26,12 @@ module dogbones() { #translate([15, 0]) dogbone_rectangle([10, 20, 5], center = false); + #translate([30, 0]) + dogbone_rectangle_x([10, 20, 5], center = false); + + #translate([45, 0]) + dogbone_rectangle_y([10, 20, 5], center = false); + sq = 3; translate([-5 + sq / 2 + eps, -10 + sq / 2 + eps]) %cube([sq, sq, 1], center = true); diff --git a/tests/png/dogbones.png b/tests/png/dogbones.png index 13f1d0f..05cb98c 100644 Binary files a/tests/png/dogbones.png and b/tests/png/dogbones.png differ diff --git a/utils/dogbones.scad b/utils/dogbones.scad index f5c3a04..f8d0030 100644 --- a/utils/dogbones.scad +++ b/utils/dogbones.scad @@ -23,24 +23,36 @@ // include <../utils/core/core.scad> -module dogbone_square(size, r = cnc_bit_r, center = true) //! Square with circles at the corners +module dogbone_square(size, r = cnc_bit_r, center = true, x_offset, y_offset) //! Square with circles at the corners, with optional offsets { + x_offset = is_undef(x_offset) ? r / sqrt(2) : x_offset; + y_offset = is_undef(y_offset) ? r / sqrt(2) : y_offset; + union() { square(size, center = center); if(r > 0) { origin = center ? [0, 0] : size / 2; - offset = r / sqrt(2); for(x = [-1, 1], y = [-1, 1]) - translate(origin + [x * (size.x / 2 - offset), y * (size.y / 2 - offset)]) + translate(origin + [x * (size.x / 2 - x_offset), y * (size.y / 2 - y_offset)]) drill(r, 0); } } } -module dogbone_rectangle(size, r = cnc_bit_r, center = true, xy_center = true) //! Rectangle with cylinders at the corners +module dogbone_rectangle(size, r = cnc_bit_r, center = true, xy_center = true, x_offset, y_offset) //! Rectangle with cylinders at the corners { extrude_if(h = size.z, center = center) - dogbone_square([size.x, size.y], r, xy_center); + dogbone_square([size.x, size.y], r, xy_center, x_offset, y_offset); +} + +module dogbone_rectangle_x(size, r = cnc_bit_r, center = true, xy_center = true) //! Rectangle with cylinders at the corners, offset in the x direction +{ + dogbone_rectangle(size = size, r = r, center = center, x_offset = 0, y_offset = r); +} + +module dogbone_rectangle_y(size, r = cnc_bit_r, center = true, xy_center = true) //! Rectangle with cylinders at the corners, offset in the y direction +{ + dogbone_rectangle(size = size, r = r, center = center, x_offset = r, y_offset = 0); }