diff --git a/readme.md b/readme.md index 27dc975..29ff544 100644 --- a/readme.md +++ b/readme.md @@ -4391,7 +4391,9 @@ Just a BOM entry at the moment and cable bundle size functions for holes, plus c | Function | Description | |:--- |:--- | | `cable_bundle(cable)` | Arrangement of a bundle in a flat cable clip | +| `cable_bundle_positions(cable)` | Positions of wires in a bundle to go through a cable strip | | `cable_height(cable)` | Height in flat clip | +| `cable_is_ribbon(cable)` | Is a ribbon cable? | | `cable_radius(cable)` | Radius of a bundle of wires, see . | | `cable_width(cable)` | Width in flat clip | | `cable_wire_size(cable)` | Size of each wire in a bundle | diff --git a/tests/png/wire.png b/tests/png/wire.png index 8851755..a5ba39c 100644 Binary files a/tests/png/wire.png and b/tests/png/wire.png differ diff --git a/tests/wire.scad b/tests/wire.scad index a499710..f50ea34 100644 --- a/tests/wire.scad +++ b/tests/wire.scad @@ -25,13 +25,15 @@ bundle = [7, 1.4]; bundle_r = cable_radius(bundle); thickness = 2; -w = 50; +w = 60; d = 20; h = 40; wire_l = 90; +mouse_y = 10; +cable_pitch = 7; module wires() { - translate_z(bundle_r) + translate([0, mouse_y, bundle_r]) rotate([0, 90, 0]) { n = cable_wires(bundle); d = cable_wire_size(bundle); @@ -58,24 +60,39 @@ module wires() { rotate([90, 0, 90]) linear_extrude(thickness) difference() { - translate([-w / 2, 0]) - square([w, h]); + square([w, h]); - mouse_hole(bundle, 0, true); + translate([mouse_y, 0]) + mouse_hole(bundle, 0, true); + + for(i = [1 : 6]) + let(cable = [i, 1.4], bundle = cable_bundle(cable)) + translate([mouse_y + cable_pitch * i - bundle.x / 2, -eps]) + square([bundle.x, bundle.y]); } translate_z(-thickness) linear_extrude(thickness) difference() { - translate([thickness -d, -w / 2]) + translate([thickness -d, 0]) square([d, w]); - translate([-15, 0]) + translate([-15, mouse_y]) cable_tie_holes(bundle_r, 0); } } - translate([-15, 0]) + translate([-15, mouse_y]) cable_tie(bundle_r, thickness); + + for(i = [1 : 6]) let(cable = [i, 1.4]) + translate([0, mouse_y + cable_pitch * i]) + let(positions = cable_bundle_positions(cable)) + for(i = [0 : len(positions) - 1]) + let(p = positions[i]) + translate([0, p.x, p.y]) + rotate([0, 90, 0]) + color([grey(10), "blue", "red", "orange", "yellow", "green"][i]) + cylinder(d = cable_wire_size(cable), h = 60, center = true); } if($preview) diff --git a/vitamins/wire.scad b/vitamins/wire.scad index 99ee7f6..0cfaa6b 100644 --- a/vitamins/wire.scad +++ b/vitamins/wire.scad @@ -34,6 +34,7 @@ module ribbon_cable(ways, length) //! Add ribbon cable to the // function cable_wires(cable) = cable[0]; //! Number of wires in a bundle function cable_wire_size(cable) = cable[1]; //! Size of each wire in a bundle +function cable_is_ribbon(cable) = len(cable) > 2 && cable[2]; //! Is a ribbon cable? // numbers from http://mathworld.wolfram.com/CirclePacking.html function cable_radius(cable) = [0, 1, 2, 2.15, 2.41, 2.7, 3, 3, 3.3][cable_wires(cable)] * cable_wire_size(cable) / 2; //! Radius of a bundle of wires, see . @@ -41,10 +42,20 @@ function cable_radius(cable) = [0, 1, 2, 2.15, 2.41, 2.7, 3, 3, 3.3][cable_wires function wire_hole_radius(cable) = ceil(4 * cable_radius(cable) + 1) / 4; //! Radius of a hole to accept a bundle of wires, rounded up to standard metric drill size function cable_bundle(cable) = //! Arrangement of a bundle in a flat cable clip - [[0,0], [1,1], [2,1], [2, 0.5 + sin(60)], [2,2], [3, 0.5 + sin(60)], [3,2]][cable_wires(cable)]; + (cable_is_ribbon(cable) ? [cable_wires(cable), 1] : + [[0,0], [1,1], [2,1], [2, 1 + sin(60)], [2,2], [3, 1 + sin(60)], [3,2]][cable_wires(cable)]) * cable_wire_size(cable); -function cable_width(cable) = cable_bundle(cable)[0] * cable_wire_size(cable); //! Width in flat clip -function cable_height(cable) = cable_bundle(cable)[1] * cable_wire_size(cable); //! Height in flat clip +function cable_bundle_positions(cable) = let( //! Positions of wires in a bundle to go through a cable strip + wires = cable_wires(cable), + bottom = cable_is_ribbon(cable) ? wires : wires < 3 ? wires : ceil(wires / 2), + top = wires - bottom + ) + [for(i = [0 : 1 : bottom - 1]) [i - (bottom - 1) / 2, 0.5], + for(i = [0 : 1 : top - 1]) [i - (top - 1) / 2, top == bottom ? 1.5 : 0.5 + sin(60)] + ] * cable_wire_size(cable); + +function cable_width(cable) = cable_bundle(cable).x; //! Width in flat clip +function cable_height(cable) = cable_bundle(cable).y; //! Height in flat clip module mouse_hole(cable, h = 100, teardrop = false) { //! A mouse hole to allow a panel to go over a wire bundle. r = wire_hole_radius(cable);