From 0a00f244e41222b00a55c10ba141c100fe7a7775 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Mon, 21 Dec 2020 23:28:39 +0000 Subject: [PATCH] Added dogbones with circles offset in x and y directions. --- tests/dogbones.scad | 6 ++++++ utils/dogbones.scad | 32 +++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) 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/utils/dogbones.scad b/utils/dogbones.scad index f5c3a04..c893545 100644 --- a/utils/dogbones.scad +++ b/utils/dogbones.scad @@ -23,24 +23,50 @@ // include <../utils/core/core.scad> -module dogbone_square(size, r = cnc_bit_r, center = true) //! Square with circles at the corners +module dogbone(size, r, center, offset_x, offset_y) //! Dogbone utility module { 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 - offset_x), y * (size.y / 2 - offset_y)]) drill(r, 0); } } } +module dogbone_square(size, r = cnc_bit_r, center = true) //! Square with circles at the corners +{ + dogbone([size.x, size.y], r, center, r / sqrt(2), r / sqrt(2)); +} + +module dogbone_square_x(size, r = cnc_bit_r, center = true) //! Square with circles at the corners, offset in the x direction +{ + dogbone([size.x, size.y], r, center, 0, r); +} + +module dogbone_square_y(size, r = cnc_bit_r, center = true) //! Square with circles at the corners, offset in the y direction +{ + dogbone([size.x, size.y], r, center, r, 0); +} + module dogbone_rectangle(size, r = cnc_bit_r, center = true, xy_center = true) //! Rectangle with cylinders at the corners { extrude_if(h = size.z, center = center) dogbone_square([size.x, size.y], r, xy_center); } + +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 +{ + extrude_if(h = size.z, center = center) + dogbone_square_x([size.x, size.y], r, xy_center); +} + +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 +{ + extrude_if(h = size.z, center = center) + dogbone_square_y([size.x, size.y], r, xy_center); +}