1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-01-17 05:28:14 +01:00

Fixed ziptie bug for small wires and corners made sharper.

This commit is contained in:
Chris Palmer 2022-03-17 20:48:43 +00:00
parent b70911dc13
commit 99a5570e24
4 changed files with 18 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -16,14 +16,23 @@
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
wire_r = 5; // [1 : 20]
t = 0; // [0 : 3]
include <../utils/core/core.scad>
use <../utils/layout.scad>
include <../vitamins/zipties.scad>
module zipties()
layout([for(z = zipties) 9], 10)
ziptie(zipties[$i], 5);
layout([for(z = zipties) 9], 2 * wire_r) {
ziptie(zipties[$i], wire_r, t);
if(t)
color(grey(20))
cylinder(r = wire_r, h = 10, center = true);
}
if($preview)
zipties();

View File

@ -33,17 +33,16 @@ function ziptie_tail(type) = type[5]; //! The length without teeth
module ziptie(type, r = 5, t = 0) //! Draw specified ziptie wrapped around radius `r` and optionally through panel thickness `t`
{
latch = ziptie_latch(type);
lx = latch.x / 2;
zt = ziptie_thickness(type);
cr = zt; // sharp corner radius
lx = min(latch.x / 2, r + zt / 2);
right_bulge = (r > lx - zt / 2) || !t;
cr = zt / 2; // sharp corner radius
z = r + t - cr;
x = r - cr;
inside_corners = t ? [ [0, 0, r], [-x, z, cr], [x, z, cr] ] : [];
outside_corners = t ? [ [0, 0, r + zt], [-x, z, cr + zt], [x, z, cr + zt] ] : [];
x1 = lx - zt / 2;
x2 = x1 + x1 * zt / r;
inside_path = concat([ [0, 0, r], [x1, -r, eps] ], inside_corners);
outside_path = concat([ [0, 0, r + zt], [x2, -r - zt, eps] ], outside_corners);
outside_path = concat([ if(right_bulge) [0, 0, r + zt], [x2, -r - zt, eps] ], outside_corners);
tangents = rounded_polygon_tangents(outside_path);
length = ceil(rounded_polygon_length(outside_path, tangents) + ziptie_tail(type) + latch.z + 1);
@ -56,7 +55,9 @@ module ziptie(type, r = 5, t = 0) //! Draw specified ziptie wrapped around radiu
linear_extrude(width, center = true)
difference() {
rounded_polygon(outside_path, tangents);
rounded_polygon(inside_path);
offset(-zt)
rounded_polygon(outside_path, tangents);
}
translate([lx, -r])