mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-08-22 23:23:01 +02:00
Cable clips can now use inserts or nut traps.
This commit is contained in:
BIN
libtest.png
BIN
libtest.png
Binary file not shown.
Before Width: | Height: | Size: 1001 KiB After Width: | Height: | Size: 1001 KiB |
@@ -18,7 +18,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
//! Cable clips to order. Can be for one or two cables of different sizes. Can use an insert and a screw from below or a screw and nut either way up.
|
//! Cable clips to order. Can be for one or two cables of different sizes. Can use an insert and a screw from below or a screw and nut, nyloc or plain, either way up.
|
||||||
//
|
//
|
||||||
include <../core.scad>
|
include <../core.scad>
|
||||||
use <../vitamins/wire.scad>
|
use <../vitamins/wire.scad>
|
||||||
@@ -30,27 +30,29 @@ wall = 2;
|
|||||||
function cable_clip_insert(screw, insert = true) = //! Insert type for clip, given screw.
|
function cable_clip_insert(screw, insert = true) = //! Insert type for clip, given screw.
|
||||||
is_list(insert) ? insert : insert ? screw_insert(screw, true) : false;
|
is_list(insert) ? insert : insert ? screw_insert(screw, true) : false;
|
||||||
|
|
||||||
function cable_clip_width(screw, insert = false) = //! Width given the `screw` and possibly insert.
|
function cable_clip_width(screw, insert = false, nut = false) = //! Width given the `screw` and possibly insert or nut.
|
||||||
let(insert = cable_clip_insert(screw, insert))
|
let(insert = cable_clip_insert(screw, insert))
|
||||||
insert ? 2 * (insert_hole_radius(insert) + wall) :
|
insert ? 2 * (insert_hole_radius(insert) + wall) :
|
||||||
max(wall + 2 * screw_clearance_radius(screw) + wall, washer_diameter(screw_washer(screw)));
|
nut ? 2 * (nut_radius(screw_nut(screw)) + wall) :
|
||||||
|
max(wall + 2 * screw_clearance_radius(screw) + wall, washer_diameter(screw_washer(screw)));
|
||||||
|
|
||||||
function cable_clip_height(cable, screw = false, insert = false) = //! Height given the `cable`.
|
function cable_clip_height(cable, screw = false, insert = false, nut = false) = //! Height given the `cable`.
|
||||||
let(insert = cable_clip_insert(screw, insert))
|
let(insert = cable_clip_insert(screw, insert))
|
||||||
max(cable_height(cable) + wall, insert ? insert_hole_length(insert) + 1 : 0);
|
max(cable_height(cable) + wall, insert ? insert_hole_length(insert) + 1 : 0, nut ? nut_trap_depth(screw_nut(screw)) + wall : 0);
|
||||||
|
|
||||||
function cable_clip_extent(screw, cable, insert = false) = cable_clip_width(screw, insert) / 2 + cable_width(cable) + wall; //! How far it extends from the screw.
|
function cable_clip_extent(screw, cable, insert = false, nut = false) = cable_clip_width(screw, insert, nut) / 2 + cable_width(cable) + wall; //! How far it extends from the screw.
|
||||||
function cable_clip_offset(screw, cable, insert = false) = cable_clip_width(screw, insert) / 2 + cable_width(cable) / 2; //! The offset of the cable from the screw.
|
function cable_clip_offset(screw, cable, insert = false, nut = false) = cable_clip_width(screw, insert, nut) / 2 + cable_width(cable) / 2; //! The offset of the cable from the screw.
|
||||||
|
|
||||||
module single_cable_clip(screw, cable, h = 0, insert = false) {
|
module single_cable_clip(screw, cable, h = 0, insert = false, nut = false) {
|
||||||
insert = cable_clip_insert(screw, insert);
|
insert = cable_clip_insert(screw, insert);
|
||||||
height = cable_clip_width(screw, insert);
|
height = cable_clip_width(screw, insert, nut);
|
||||||
depth = h ? h : cable_clip_height(cable, screw, insert);
|
depth = h ? h : cable_clip_height(cable, screw, insert, nut);
|
||||||
w = cable_width(cable);
|
w = cable_width(cable);
|
||||||
width = wall + w + height;
|
width = wall + w + height;
|
||||||
hole_x = wall + w + height / 2;
|
hole_x = wall + w + height / 2;
|
||||||
rad = min(wall + cable_wire_size(cable) / 2, depth / 2);
|
rad = min(wall + cable_wire_size(cable) / 2, depth / 2);
|
||||||
r = extrusion_width - eps;
|
r = extrusion_width - eps;
|
||||||
|
the_nut = screw_nut(screw);
|
||||||
translate([-hole_x, 0])
|
translate([-hole_x, 0])
|
||||||
difference() {
|
difference() {
|
||||||
linear_extrude(height)
|
linear_extrude(height)
|
||||||
@@ -85,62 +87,68 @@ module single_cable_clip(screw, cable, h = 0, insert = false) {
|
|||||||
if(insert)
|
if(insert)
|
||||||
insert_hole(insert, 10, horizontal = true);
|
insert_hole(insert, 10, horizontal = true);
|
||||||
else
|
else
|
||||||
teardrop_plus(h = 2 * depth + 1, r = screw_clearance_radius(screw), center = true);
|
if(nut) {
|
||||||
|
translate_z(depth - wall - nut_trap_depth(the_nut))
|
||||||
|
nut_trap(screw, the_nut, horizontal = true);
|
||||||
|
nut_trap(screw, the_nut, horizontal = true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
teardrop_plus(h = 2 * depth + 1, r = screw_clearance_radius(screw), center = true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module double_cable_clip(screw, cable1, cable2, insert = false) {
|
module double_cable_clip(screw, cable1, cable2, insert = false, nut = false) {
|
||||||
h = max(cable_clip_height(cable1, screw, insert), cable_clip_height(cable2, screw, insert));
|
h = max(cable_clip_height(cable1, screw, insert, nut), cable_clip_height(cable2, screw, insert, nut));
|
||||||
union() {
|
union() {
|
||||||
single_cable_clip(screw, cable1, h, insert);
|
single_cable_clip(screw, cable1, h, insert, nut);
|
||||||
|
|
||||||
mirror([1,0,0]) single_cable_clip(screw, cable2, h, insert);
|
mirror([1,0,0]) single_cable_clip(screw, cable2, h, insert, nut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module cable_clip(screw, cable1, cable2 = 0, insert = false) { //! Create the STL for a single cable or two cable clip
|
module cable_clip(screw, cable1, cable2 = 0, insert = false, nut = false) { //! Create the STL for a single cable or two cable clip
|
||||||
function clip_str(screw) = str("cable_clip_", screw_radius(screw) * 20, insert ? "I" : "");
|
function clip_str(screw) = str("cable_clip_", screw_radius(screw) * 20, insert ? "I" : nut ? "N" : "");
|
||||||
function cable_str(cable) = str("_", cable_wires(cable), "_", round(cable_wire_size(cable) * 10));
|
function cable_str(cable) = str("_", cable_wires(cable), "_", round(cable_wire_size(cable) * 10));
|
||||||
|
assert(!(insert && nut), "insert and nut mutually exclusive");
|
||||||
if(cable2) {
|
if(cable2)
|
||||||
stl(str(clip_str(screw), cable_str(cable1), cable_str(cable2)));
|
stl(str(clip_str(screw), cable_str(cable1), cable_str(cable2)))
|
||||||
|
double_cable_clip(screw, cable1, cable2, insert, nut);
|
||||||
double_cable_clip(screw, cable1, cable2, insert);
|
else
|
||||||
}
|
stl(str(clip_str(screw), cable_str(cable1)))
|
||||||
else {
|
single_cable_clip(screw, cable1, h = 0, insert = insert, nut = nut);
|
||||||
stl(str(clip_str(screw), cable_str(cable1)));
|
|
||||||
|
|
||||||
single_cable_clip(screw, cable1, h = 0, insert = insert);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module cable_clip_assembly(screw, thickness, cable1, cable2 = 0, flip = false, insert = false, nut = false, nyloc = true) { //! Cable clip with the fasteners
|
||||||
module cable_clip_assembly(screw, thickness, cable1, cable2 = 0, flip = false, insert = false) { //! Cable clip with the fasteners
|
flip = flip || insert || nut; // Screw must be below if using an insert or nut
|
||||||
flip = flip || insert; // Screw must be below if using an insert
|
|
||||||
insert = cable_clip_insert(screw, insert);
|
insert = cable_clip_insert(screw, insert);
|
||||||
height = max(cable_clip_height(cable1, screw, insert), cable2 ? cable_clip_height(cable2, screw, insert) : 0);
|
height = max(cable_clip_height(cable1, screw, insert, nut), cable2 ? cable_clip_height(cable2, screw, insert, nut) : 0);
|
||||||
|
|
||||||
stl_colour(pp1_colour) render()
|
stl_colour(pp1_colour) render()
|
||||||
translate([0, cable_clip_width(screw, insert) / 2])
|
translate([0, cable_clip_width(screw, insert, nut) / 2])
|
||||||
rotate([90, 0, 0])
|
rotate([90, 0, 0])
|
||||||
cable_clip(screw, cable1, cable2, insert);
|
cable_clip(screw, cable1, cable2, insert, nut);
|
||||||
|
|
||||||
nut = screw_nut(screw);
|
the_nut = screw_nut(screw);
|
||||||
screw_len = screw_length(screw, height + thickness, 2, nyloc = !insert, insert = insert);
|
screw_len = nut ? screw_length(screw, thickness + wall, nyloc ? 1 : 2, nyloc = nyloc, nut = !nyloc)
|
||||||
|
: screw_length(screw, thickness + height, 2, nut = !nyloc && !insert, nyloc = !insert && nyloc, insert = insert);
|
||||||
translate_z(height)
|
translate_z(height)
|
||||||
if(flip)
|
if(flip)
|
||||||
if(insert)
|
if(insert)
|
||||||
insert(insert);
|
insert(insert);
|
||||||
else
|
else
|
||||||
nut_and_washer(nut, true);
|
if(nut)
|
||||||
|
translate_z(-height + wall)
|
||||||
|
nut(the_nut, nyloc);
|
||||||
|
else
|
||||||
|
nut_and_washer(the_nut, nyloc);
|
||||||
else
|
else
|
||||||
screw_and_washer(screw, screw_len);
|
screw_and_washer(screw, screw_len);
|
||||||
|
|
||||||
translate_z(-thickness)
|
translate_z(-thickness)
|
||||||
vflip()
|
vflip()
|
||||||
if(flip)
|
if(flip)
|
||||||
screw_and_washer(screw, screw_len, insert);
|
screw_and_washer(screw, screw_len, insert || !nyloc);
|
||||||
else
|
else
|
||||||
nut_and_washer(nut, true);
|
nut_and_washer(the_nut, nyloc);
|
||||||
}
|
}
|
||||||
|
22
readme.md
22
readme.md
@@ -5365,7 +5365,7 @@ fixing_blocks along the sides.
|
|||||||
---
|
---
|
||||||
<a name="cable_clip"></a>
|
<a name="cable_clip"></a>
|
||||||
## Cable_clip
|
## Cable_clip
|
||||||
Cable clips to order. Can be for one or two cables of different sizes. Can use an insert and a screw from below or a screw and nut either way up.
|
Cable clips to order. Can be for one or two cables of different sizes. Can use an insert and a screw from below or a screw and nut, nyloc or plain, either way up.
|
||||||
|
|
||||||
[printed/cable_clip.scad](printed/cable_clip.scad) Implementation.
|
[printed/cable_clip.scad](printed/cable_clip.scad) Implementation.
|
||||||
|
|
||||||
@@ -5374,17 +5374,17 @@ Cable clips to order. Can be for one or two cables of different sizes. Can use a
|
|||||||
### Functions
|
### Functions
|
||||||
| Function | Description |
|
| Function | Description |
|
||||||
|:--- |:--- |
|
|:--- |:--- |
|
||||||
| `cable_clip_extent(screw, cable, insert = false)` | How far it extends from the screw. |
|
| `cable_clip_extent(screw, cable, insert = false, nut = false)` | How far it extends from the screw. |
|
||||||
| `cable_clip_height(cable, screw = false, insert = false)` | Height given the `cable`. |
|
| `cable_clip_height(cable, screw = false, insert = false, nut = false)` | Height given the `cable`. |
|
||||||
| `cable_clip_insert(screw, insert = true)` | Insert type for clip, given screw. |
|
| `cable_clip_insert(screw, insert = true)` | Insert type for clip, given screw. |
|
||||||
| `cable_clip_offset(screw, cable, insert = false)` | The offset of the cable from the screw. |
|
| `cable_clip_offset(screw, cable, insert = false, nut = false)` | The offset of the cable from the screw. |
|
||||||
| `cable_clip_width(screw, insert = false)` | Width given the `screw` and possibly insert. |
|
| `cable_clip_width(screw, insert = false, nut = false)` | Width given the `screw` and possibly insert or nut. |
|
||||||
|
|
||||||
### Modules
|
### Modules
|
||||||
| Module | Description |
|
| Module | Description |
|
||||||
|:--- |:--- |
|
|:--- |:--- |
|
||||||
| `cable_clip(screw, cable1, cable2 = 0, insert = false)` | Create the STL for a single cable or two cable clip |
|
| `cable_clip(screw, cable1, cable2 = 0, insert = false, nut = false)` | Create the STL for a single cable or two cable clip |
|
||||||
| `cable_clip_assembly(screw, thickness, cable1, cable2 = 0, flip = false, insert = false)` | Cable clip with the fasteners |
|
| `cable_clip_assembly(screw, thickness, cable1, cable2 = 0, flip = false, insert = false, nut = false, nyloc = true)` | Cable clip with the fasteners |
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -5393,10 +5393,10 @@ Cable clips to order. Can be for one or two cables of different sizes. Can use a
|
|||||||
| ---:|:--- |:---|
|
| ---:|:--- |:---|
|
||||||
| 2 | `insert(CNCKM3)` | Heatfit insert M3 x 3mm |
|
| 2 | `insert(CNCKM3)` | Heatfit insert M3 x 3mm |
|
||||||
| 5 | `nut(M3_nut, nyloc = true)` | Nut M3 x 2.4mm nyloc |
|
| 5 | `nut(M3_nut, nyloc = true)` | Nut M3 x 2.4mm nyloc |
|
||||||
| 2 | `screw(M3_dome_screw, 10)` | Screw M3 dome x 10mm |
|
| 3 | `screw(M3_dome_screw, 10)` | Screw M3 dome x 10mm |
|
||||||
| 1 | `screw(M3_dome_screw, 12)` | Screw M3 dome x 12mm |
|
| 1 | `screw(M3_dome_screw, 12)` | Screw M3 dome x 12mm |
|
||||||
| 4 | `screw(M3_dome_screw, 16)` | Screw M3 dome x 16mm |
|
| 3 | `screw(M3_dome_screw, 16)` | Screw M3 dome x 16mm |
|
||||||
| 12 | `washer(M3_washer)` | Washer M3 x 7mm x 0.5mm |
|
| 11 | `washer(M3_washer)` | Washer M3 x 7mm x 0.5mm |
|
||||||
| 2 | `star_washer(M3_washer)` | Washer star M3 x 0.5mm |
|
| 2 | `star_washer(M3_washer)` | Washer star M3 x 0.5mm |
|
||||||
|
|
||||||
### Printed
|
### Printed
|
||||||
@@ -5404,10 +5404,10 @@ Cable clips to order. Can be for one or two cables of different sizes. Can use a
|
|||||||
| ---:|:--- |
|
| ---:|:--- |
|
||||||
| 1 | cable_clip_30I_10_13.stl |
|
| 1 | cable_clip_30I_10_13.stl |
|
||||||
| 1 | cable_clip_30I_5_14_6_14.stl |
|
| 1 | cable_clip_30I_5_14_6_14.stl |
|
||||||
|
| 1 | cable_clip_30N_7_14_8_14.stl |
|
||||||
| 1 | cable_clip_30_1_14_2_14.stl |
|
| 1 | cable_clip_30_1_14_2_14.stl |
|
||||||
| 1 | cable_clip_30_1_60.stl |
|
| 1 | cable_clip_30_1_60.stl |
|
||||||
| 1 | cable_clip_30_3_14_4_14.stl |
|
| 1 | cable_clip_30_3_14_4_14.stl |
|
||||||
| 1 | cable_clip_30_7_14_8_14.stl |
|
|
||||||
| 1 | cable_clip_30_9_14.stl |
|
| 1 | cable_clip_30_9_14.stl |
|
||||||
|
|
||||||
|
|
||||||
|
@@ -20,33 +20,39 @@
|
|||||||
include <../core.scad>
|
include <../core.scad>
|
||||||
use <../printed/cable_clip.scad>
|
use <../printed/cable_clip.scad>
|
||||||
use <../vitamins/wire.scad>
|
use <../vitamins/wire.scad>
|
||||||
|
use <../utils/layout.scad>
|
||||||
|
|
||||||
|
screw = M3_dome_screw;
|
||||||
sheet_thickness = 3;
|
sheet_thickness = 3;
|
||||||
|
|
||||||
cables = [
|
cables = [
|
||||||
[10, inch(0.05), true], 0, for(i = [1 : 9]) [i, 1.4], 0, [1, 6], 0,
|
[10, inch(0.05), true], 0, for(i = [1 : 9]) [i, 1.4], 0, [1, 6], 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
screw = M3_dome_screw;
|
clips = [for(i = [0 : ceil(len(cables) / 2) - 1]) let(c1= cables[2 * i], c2 = cables[2 * i + 1]) [c1, c2]];
|
||||||
|
|
||||||
|
function use_insert(i) = in([0, 3], i);
|
||||||
|
function use_nut(i) = in([4], i);
|
||||||
|
|
||||||
|
clip_lengths = [for(i = [0 : len(clips) - 1])
|
||||||
|
let(c = clips[i], c1 = c.x, c2 = c.y, ins = use_insert(i), nut = use_nut(i))
|
||||||
|
cable_clip_extent(screw, c1, insert = ins, nut = nut) + (c2 ? cable_clip_extent(screw, c2, insert = ins, nut = nut) : cable_clip_width(screw, insert = ins, nut = nut) / 2)];
|
||||||
|
|
||||||
module cable_clips() {
|
module cable_clips() {
|
||||||
for(i = [0 : ceil(len(cables) / 2) - 1]) {
|
layout(clip_lengths, 3, true) let(cable1 = clips[$i].x, cable2 = clips[$i].y) {
|
||||||
cable1 = cables[2 * i];
|
insert = use_insert($i);
|
||||||
cable2 = cables[2 * i + 1];
|
nut = use_nut($i);
|
||||||
translate([i * 21 + (!cable2 ? cable_clip_offset(screw, cable1) / 2 : 0), 0]) {
|
translate([cable_clip_extent(screw, cable1, insert = insert, nut = nut) - clip_lengths[$i] / 2, 0]) {
|
||||||
insert = in([0, 3], i);
|
|
||||||
if($preview) {
|
if($preview) {
|
||||||
cable_clip_assembly(screw, sheet_thickness, cable1, cable2, insert = insert, flip = i == 1);
|
cable_clip_assembly(screw, sheet_thickness, cable1, cable2, insert = insert, nut = nut, flip = $i == 1);
|
||||||
|
|
||||||
for(j = [0 : 1])
|
for(j = [0 : 1])
|
||||||
let(cable = cables[2 * i + j])
|
let(cable = clips[$i][j])
|
||||||
if(cable)
|
if(cable)
|
||||||
let(positions = cable_bundle_positions(cable))
|
let(positions = cable_bundle_positions(cable))
|
||||||
for(i = [0 : len(positions) - 1])
|
for(i = [0 : len(positions) - 1])
|
||||||
let(p = positions[i])
|
let(p = positions[i])
|
||||||
translate([p.x + [-1, 1][j] * cable_clip_offset(screw, cable, insert = insert), 0, p.y])
|
translate([p.x + [-1, 1][j] * cable_clip_offset(screw, cable, insert = insert, nut = nut), 0, p.y])
|
||||||
rotate([90, 0, 0])
|
rotate([90, 0, 0])
|
||||||
color([grey(20), "blue", "red", "orange", "yellow", "green", "brown", "purple", "grey", "white"][i])
|
color([grey(20), "blue", "red", "orange", "yellow", "green", "brown", "purple", "grey", "white"][i])
|
||||||
cylinder(d = cable_wire_size(cable), h = 30, center = true);
|
cylinder(d = cable_wire_size(cable), h = 30, center = true);
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 128 KiB |
Reference in New Issue
Block a user