mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-09-05 21:02:51 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ceac5cdb27 | ||
|
c5b35daeac | ||
|
ffb4512523 | ||
|
35ffbad74c | ||
|
fb685a0f42 |
BIN
libtest.png
BIN
libtest.png
Binary file not shown.
Before Width: | Height: | Size: 848 KiB After Width: | Height: | Size: 848 KiB |
@@ -23,12 +23,20 @@
|
|||||||
//! Each link has a maximum bend angle of 45°, so the mininium radius is proportional to the link length.
|
//! Each link has a maximum bend angle of 45°, so the mininium radius is proportional to the link length.
|
||||||
//!
|
//!
|
||||||
//! The travel property is how far it can move in each direction, i.e. half the maximum travel if the chain is mounted in the middle of the travel.
|
//! The travel property is how far it can move in each direction, i.e. half the maximum travel if the chain is mounted in the middle of the travel.
|
||||||
|
//!
|
||||||
|
//! The ends can have screw lugs with four screw positions to choose from, specified by a list of two arrays of four bools.
|
||||||
|
//! If none are enabled then a child object is expected to customise the end and this gets unioned with the blank end.
|
||||||
|
//! If both ends are customised then two children are expected.
|
||||||
|
//! Each child is called twice, once with ```$fasteners``` set to 0 to augment the STL and again with ```$fasteners``` set to 1 to add
|
||||||
|
//! to the assembly, for example to add inserts.
|
||||||
//
|
//
|
||||||
|
|
||||||
include <../core.scad>
|
include <../core.scad>
|
||||||
use <../utils/horiholes.scad>
|
use <../utils/horiholes.scad>
|
||||||
use <../utils/maths.scad>
|
use <../utils/maths.scad>
|
||||||
|
|
||||||
|
clearance = 0.1;
|
||||||
|
|
||||||
function drag_chain_name(type) = type[0]; //! The name to allow more than one in a project
|
function drag_chain_name(type) = type[0]; //! The name to allow more than one in a project
|
||||||
function drag_chain_size(type) = type[1]; //! The internal size and link length
|
function drag_chain_size(type) = type[1]; //! The internal size and link length
|
||||||
function drag_chain_travel(type) = type[2]; //! X travel
|
function drag_chain_travel(type) = type[2]; //! X travel
|
||||||
@@ -38,6 +46,8 @@ function drag_chain_twall(type) = type[5]; //! Top wall
|
|||||||
function drag_chain_screw(type) = type[6]; //! Mounting screw for the ends
|
function drag_chain_screw(type) = type[6]; //! Mounting screw for the ends
|
||||||
function drag_chain_screw_lists(type) = type[7]; //! Two lists of four bools to say which screws positions are used
|
function drag_chain_screw_lists(type) = type[7]; //! Two lists of four bools to say which screws positions are used
|
||||||
|
|
||||||
|
function drag_chain_clearance() = clearance; //! Clearance around joints.
|
||||||
|
|
||||||
function drag_chain_radius(type) = //! The bend radius at the pivot centres
|
function drag_chain_radius(type) = //! The bend radius at the pivot centres
|
||||||
let(s = drag_chain_size(type))
|
let(s = drag_chain_size(type))
|
||||||
s.x / 2 / sin(360 / 16);
|
s.x / 2 / sin(360 / 16);
|
||||||
@@ -49,8 +59,6 @@ function drag_chain_z(type) = //! Outside dimension of a 180 bend
|
|||||||
function drag_chain(name, size, travel, wall = 1.6, bwall = 1.5, twall = 1.5, screw = M2_cap_screw, screw_lists = [[1,0,0,1],[1,0,0,1]]) = //! Constructor
|
function drag_chain(name, size, travel, wall = 1.6, bwall = 1.5, twall = 1.5, screw = M2_cap_screw, screw_lists = [[1,0,0,1],[1,0,0,1]]) = //! Constructor
|
||||||
[name, size, travel, wall, bwall, twall, screw, screw_lists];
|
[name, size, travel, wall, bwall, twall, screw, screw_lists];
|
||||||
|
|
||||||
clearance = 0.1;
|
|
||||||
|
|
||||||
function drag_chain_outer_size(type) = //! Link outer dimensions
|
function drag_chain_outer_size(type) = //! Link outer dimensions
|
||||||
let(s = drag_chain_size(type), z = s.z + drag_chain_bwall(type) + drag_chain_twall(type))
|
let(s = drag_chain_size(type), z = s.z + drag_chain_bwall(type) + drag_chain_twall(type))
|
||||||
[s.x + z, s.y + 4 * drag_chain_wall(type) + 2 * clearance, z];
|
[s.x + z, s.y + 4 * drag_chain_wall(type) + 2 * clearance, z];
|
||||||
@@ -210,9 +218,12 @@ module drag_chain_link(type, start = false, end = false) { //! One link of the c
|
|||||||
translate([floor_x, -os.y / 2 + 0.5, os.z - bwall])
|
translate([floor_x, -os.y / 2 + 0.5, os.z - bwall])
|
||||||
cube([s.x - floor_x - clearance, os.y -1, bwall]);
|
cube([s.x - floor_x - clearance, os.y -1, bwall]);
|
||||||
|
|
||||||
if(start || end)
|
if(start || end) {
|
||||||
drag_chain_screw_positions(type, end)
|
drag_chain_screw_positions(type, end)
|
||||||
screw_lug(drag_chain_screw(type), os.z);
|
screw_lug(drag_chain_screw(type), os.z);
|
||||||
|
|
||||||
|
children();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(start || end)
|
if(start || end)
|
||||||
translate_z(-eps)
|
translate_z(-eps)
|
||||||
@@ -243,7 +254,8 @@ module drag_chain_link(type, start = false, end = false) { //! One link of the c
|
|||||||
//! 1. Clip the links together with the special ones at the ends.
|
//! 1. Clip the links together with the special ones at the ends.
|
||||||
module drag_chain_assembly(type, pos = 0) { //! Drag chain assembly
|
module drag_chain_assembly(type, pos = 0) { //! Drag chain assembly
|
||||||
s = drag_chain_size(type);
|
s = drag_chain_size(type);
|
||||||
r = drag_chain_radius(type);
|
x = (1 + exploded()) * s.x;
|
||||||
|
r = drag_chain_radius(type) * x / s.x;
|
||||||
travel = drag_chain_travel(type);
|
travel = drag_chain_travel(type);
|
||||||
links = ceil(travel / s.x);
|
links = ceil(travel / s.x);
|
||||||
actual_travel = links * s.x;
|
actual_travel = links * s.x;
|
||||||
@@ -255,31 +267,42 @@ module drag_chain_assembly(type, pos = 0) { //! Drag chain assembly
|
|||||||
points = [ // Calculate list of hinge points
|
points = [ // Calculate list of hinge points
|
||||||
for(i = 0, p = [0, 0, z / 2 + 2 * r]; i < links + 5;
|
for(i = 0, p = [0, 0, z / 2 + 2 * r]; i < links + 5;
|
||||||
i = i + 1,
|
i = i + 1,
|
||||||
dx = p.z > c.z ? s.x : -s.x,
|
dx = p.z > c.z ? x : -x,
|
||||||
p = max(p.x + dx, p.x) <= c.x ? p + [dx, 0, 0] // Straight sections
|
p = max(p.x + dx, p.x) <= c.x ? p + [dx, 0, 0] // Straight sections
|
||||||
: let(q = circle_intersect(p, s.x, c, r))
|
: let(q = circle_intersect(p, x, c, r))
|
||||||
q.x <= c.x ? [p.x - sqrt(sqr(s.x) - sqr(p.z - zb)), 0, zb] // Transition back to straight
|
q.x <= c.x ? [p.x - sqrt(sqr(x) - sqr(p.z - zb)), 0, zb] // Transition back to straight
|
||||||
: q) // Circular section
|
: q) // Circular section
|
||||||
p
|
p
|
||||||
];
|
];
|
||||||
npoints = len(points);
|
npoints = len(points);
|
||||||
|
|
||||||
module link(n) // Position and colour link with origin at the hinge hole
|
module link(n) // Position and colour link with origin at the hinge hole
|
||||||
translate([-z / 2, 0, -z / 2])
|
translate([-z / 2, 0, -z / 2]) {
|
||||||
stl_colour(n % 2 ? pp1_colour : pp2_colour)
|
stl_colour(n < 0 || n == npoints - 1 ? pp3_colour : n % 2 ? pp1_colour : pp2_colour)
|
||||||
drag_chain_link(type, start = n == -1, end = n == npoints - 1);
|
drag_chain_link(type, start = n == -1, end = n == npoints - 1)
|
||||||
|
let($fasteners = 0) children();
|
||||||
|
let($fasteners = 1) children();
|
||||||
|
}
|
||||||
|
|
||||||
|
screws = drag_chain_screw_lists(type);
|
||||||
|
custom_start = screws[0] == [0, 0, 0, 0];
|
||||||
|
custom_end = screws[1] == [0, 0, 0, 0];
|
||||||
|
assert($children == bool2int(custom_start) + bool2int(custom_end), "wrong number of children for end customisation");
|
||||||
assembly(str(drag_chain_name(type), "_drag_chain")) {
|
assembly(str(drag_chain_name(type), "_drag_chain")) {
|
||||||
for(i = [0 : npoints - 2]) let(v = points[i+1] - points[i])
|
for(i = [0 : npoints - 2]) let(v = points[i+1] - points[i])
|
||||||
translate(points[i])
|
translate(points[i])
|
||||||
rotate([0, -atan2(v.z, v.x), 0])
|
rotate([0, -atan2(v.z, v.x), 0])
|
||||||
link(i);
|
link(i);
|
||||||
|
|
||||||
translate(points[0] - [s.x, 0, 0])
|
translate(points[0] - [x, 0, 0])
|
||||||
link(-1);
|
link(-1)
|
||||||
|
if(custom_start)
|
||||||
|
children(0);
|
||||||
|
|
||||||
translate(points[npoints - 1])
|
translate(points[npoints - 1])
|
||||||
hflip()
|
hflip()
|
||||||
link(npoints - 1);
|
link(npoints - 1)
|
||||||
|
if(custom_end)
|
||||||
|
children(custom_start ? 1 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ module ribbon_clamp(ways, screw = screw) { //! Generate STL for given number of
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module ribbon_clamp_assembly(ways, screw) pose([55, 180, 25]) //! Printed part with inserts in place
|
module ribbon_clamp_assembly(ways, screw = screw) pose([55, 180, 25]) //! Printed part with inserts in place
|
||||||
assembly(let(screw_d = screw_radius(screw) * 2)str("ribbon_clamp_", ways, screw_d != 3 ? str("_", screw_d) : "")) {
|
assembly(let(screw_d = screw_radius(screw) * 2)str("ribbon_clamp_", ways, screw_d != 3 ? str("_", screw_d) : "")) {
|
||||||
h = ribbon_clamp_height(screw);
|
h = ribbon_clamp_height(screw);
|
||||||
insert = screw_insert(screw);
|
insert = screw_insert(screw);
|
||||||
|
10
readme.md
10
readme.md
@@ -2707,6 +2707,7 @@ Linear rails with carriages.
|
|||||||
| Function | Description |
|
| Function | Description |
|
||||||
|:--- |:--- |
|
|:--- |:--- |
|
||||||
| ```carriage_screw_depth(type)``` | Carriage thread depth |
|
| ```carriage_screw_depth(type)``` | Carriage thread depth |
|
||||||
|
| ```rail_holes(type, length)``` | Number of holes in a rail given its ```length``` |
|
||||||
| ```rail_screw_height(type, screw)``` | Position screw taking into account countersink into counterbored hole |
|
| ```rail_screw_height(type, screw)``` | Position screw taking into account countersink into counterbored hole |
|
||||||
| ```rail_travel(type, length)``` | How far the carriage can travel |
|
| ```rail_travel(type, length)``` | How far the carriage can travel |
|
||||||
|
|
||||||
@@ -4560,6 +4561,12 @@ Each link has a maximum bend angle of 45°, so the mininium radius is proport
|
|||||||
|
|
||||||
The travel property is how far it can move in each direction, i.e. half the maximum travel if the chain is mounted in the middle of the travel.
|
The travel property is how far it can move in each direction, i.e. half the maximum travel if the chain is mounted in the middle of the travel.
|
||||||
|
|
||||||
|
The ends can have screw lugs with four screw positions to choose from, specified by a list of two arrays of four bools.
|
||||||
|
If none are enabled then a child object is expected to customise the end and this gets unioned with the blank end.
|
||||||
|
If both ends are customised then two children are expected.
|
||||||
|
Each child is called twice, once with ```$fasteners``` set to 0 to augment the STL and again with ```$fasteners``` set to 1 to add
|
||||||
|
to the assembly, for example to add inserts.
|
||||||
|
|
||||||
|
|
||||||
[printed/drag_chain.scad](printed/drag_chain.scad) Implementation.
|
[printed/drag_chain.scad](printed/drag_chain.scad) Implementation.
|
||||||
|
|
||||||
@@ -4581,6 +4588,7 @@ The travel property is how far it can move in each direction, i.e. half the maxi
|
|||||||
| Function | Description |
|
| Function | Description |
|
||||||
|:--- |:--- |
|
|:--- |:--- |
|
||||||
| ```drag_chain(name, size, travel, wall = 1.6, bwall = 1.5, twall = 1.5, screw = M2_cap_screw, screw_lists = [[1,0,0,1],[1,0,0,1]])``` | Constructor |
|
| ```drag_chain(name, size, travel, wall = 1.6, bwall = 1.5, twall = 1.5, screw = M2_cap_screw, screw_lists = [[1,0,0,1],[1,0,0,1]])``` | Constructor |
|
||||||
|
| ```drag_chain_clearance()``` | Clearance around joints. |
|
||||||
| ```drag_chain_outer_size(type)``` | Link outer dimensions |
|
| ```drag_chain_outer_size(type)``` | Link outer dimensions |
|
||||||
| ```drag_chain_radius(type)``` | The bend radius at the pivot centres |
|
| ```drag_chain_radius(type)``` | The bend radius at the pivot centres |
|
||||||
| ```drag_chain_z(type)``` | Outside dimension of a 180 bend |
|
| ```drag_chain_z(type)``` | Outside dimension of a 180 bend |
|
||||||
@@ -5137,7 +5145,7 @@ Clamp for ribbon cable and polypropylene strip.
|
|||||||
| Module | Description |
|
| Module | Description |
|
||||||
|:--- |:--- |
|
|:--- |:--- |
|
||||||
| ```ribbon_clamp(ways, screw = screw)``` | Generate STL for given number of ways |
|
| ```ribbon_clamp(ways, screw = screw)``` | Generate STL for given number of ways |
|
||||||
| ```ribbon_clamp_assembly(ways, screw)``` | Printed part with inserts in place |
|
| ```ribbon_clamp_assembly(ways, screw = screw)``` | Printed part with inserts in place |
|
||||||
| ```ribbon_clamp_fastened_assembly(ways, thickness, screw = screw)``` | Clamp with fasteners in place |
|
| ```ribbon_clamp_fastened_assembly(ways, thickness, screw = screw)``` | Clamp with fasteners in place |
|
||||||
| ```ribbon_clamp_hole_positions(ways, screw = screw, side = undef)``` | Place children at hole positions |
|
| ```ribbon_clamp_hole_positions(ways, screw = screw, side = undef)``` | Place children at hole positions |
|
||||||
| ```ribbon_clamp_holes(ways, h = 20, screw = screw)``` | Drill screw holes |
|
| ```ribbon_clamp_holes(ways, h = 20, screw = screw)``` | Drill screw holes |
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 133 KiB |
@@ -23,6 +23,7 @@ use <../utils/layout.scad>
|
|||||||
use <../vitamins/nut.scad>
|
use <../vitamins/nut.scad>
|
||||||
|
|
||||||
sheet = 3;
|
sheet = 3;
|
||||||
|
pos = 1; //[-1 : 0.1 : 1]
|
||||||
|
|
||||||
module rails()
|
module rails()
|
||||||
layout([for(l = rails) carriage_width(rail_carriage(l))], 20)
|
layout([for(l = rails) carriage_width(rail_carriage(l))], 20)
|
||||||
@@ -33,7 +34,7 @@ module rails()
|
|||||||
nut = screw_nut(screw);
|
nut = screw_nut(screw);
|
||||||
washer = screw_washer(screw);
|
washer = screw_washer(screw);
|
||||||
|
|
||||||
rail_assembly(rail, length, rail_travel(rail, length) / 2, $i<2 ? grey(20) : "green", $i<2 ? grey(20) : "red");
|
rail_assembly(rail, length, pos * rail_travel(rail, length) / 2, $i<2 ? grey(20) : "green", $i<2 ? grey(20) : "red");
|
||||||
|
|
||||||
rail_screws(rail, length, sheet + nut_thickness(nut, true) + washer_thickness(washer));
|
rail_screws(rail, length, sheet + nut_thickness(nut, true) + washer_thickness(washer));
|
||||||
|
|
||||||
|
@@ -46,12 +46,16 @@ function carriage_pitch_y(type) = type[6]; //! Screw hole y pitch
|
|||||||
function carriage_screw(type) = type[7]; //! Carriage screw type
|
function carriage_screw(type) = type[7]; //! Carriage screw type
|
||||||
function carriage_screw_depth(type) = 2 * screw_radius(carriage_screw(type)); //! Carriage thread depth
|
function carriage_screw_depth(type) = 2 * screw_radius(carriage_screw(type)); //! Carriage thread depth
|
||||||
|
|
||||||
|
function rail_holes(type, length) = //! Number of holes in a rail given its ```length```
|
||||||
|
floor((length - 2 * rail_end(type)) / rail_pitch(type)) + 1;
|
||||||
|
|
||||||
module rail_hole_positions(type, length, first = 0, screws = 100, both_ends = true) { //! Position children over screw holes
|
module rail_hole_positions(type, length, first = 0, screws = 100, both_ends = true) { //! Position children over screw holes
|
||||||
pitch = rail_pitch(type);
|
pitch = rail_pitch(type);
|
||||||
holes = floor((length - 2 * rail_end(type)) / pitch) + 1;
|
holes = rail_holes(type, length);
|
||||||
for(i = [first : holes - 1 - first])
|
last = first + screws;
|
||||||
if(i < screws || (holes - i <= screws && both_ends))
|
for(i = [first : holes - 1], j = holes - 1 - i)
|
||||||
translate([i * pitch - length / 2 + (length - (holes -1) * pitch) / 2, 0, 0])
|
if(i < last || both_ends && (j >= first && j < last))
|
||||||
|
translate([i * pitch - length / 2 + (length - (holes - 1) * pitch) / 2, 0])
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,24 +108,27 @@ module carriage(type, rail, end_colour = grey(20), wiper_colour = grey(20)) { //
|
|||||||
|
|
||||||
module carriage_end(type, end_w, end_h, end_l) {
|
module carriage_end(type, end_w, end_h, end_l) {
|
||||||
wiper_length = 0.5;
|
wiper_length = 0.5;
|
||||||
color(wiper_colour) translate_z(-end_l/2) linear_extrude(wiper_length)
|
color(wiper_colour) translate_z(-end_l / 2) linear_extrude(wiper_length)
|
||||||
difference() {
|
difference() {
|
||||||
translate([-end_w/2, carriage_clearance(type)])
|
translate([-end_w / 2, carriage_clearance(type)])
|
||||||
square([end_w, end_h]);
|
square([end_w, end_h]);
|
||||||
|
|
||||||
cutout();
|
cutout();
|
||||||
}
|
}
|
||||||
color(end_colour) translate_z(wiper_length-end_l/2) linear_extrude(end_l-wiper_length)
|
color(end_colour) translate_z(wiper_length-end_l / 2) linear_extrude(end_l - wiper_length)
|
||||||
difference() {
|
difference() {
|
||||||
translate([-end_w/2, carriage_clearance(type)])
|
translate([-end_w / 2, carriage_clearance(type)])
|
||||||
square([end_w, end_h]);
|
square([end_w, end_h]);
|
||||||
|
|
||||||
cutout();
|
cutout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
translate([-(block_l+end_l)/2,0,0])
|
translate([-(block_l + end_l) / 2, 0])
|
||||||
rotate([90, 0, 90])
|
rotate([90, 0, 90])
|
||||||
carriage_end(type, end_w, end_h, end_l);
|
carriage_end(type, end_w, end_h, end_l);
|
||||||
translate([(block_l+end_l)/2,0,0])
|
|
||||||
|
translate([(block_l + end_l) / 2, 0])
|
||||||
rotate([90, 0, -90])
|
rotate([90, 0, -90])
|
||||||
carriage_end(type, end_w, end_h, end_l);
|
carriage_end(type, end_w, end_h, end_l);
|
||||||
}
|
}
|
||||||
@@ -171,7 +178,6 @@ module rail_assembly(type, length, pos, carriage_end_colour = grey(20), carriage
|
|||||||
|
|
||||||
translate([pos, 0])
|
translate([pos, 0])
|
||||||
carriage(rail_carriage(type), type, carriage_end_colour, carriage_wiper_colour);
|
carriage(rail_carriage(type), type, carriage_end_colour, carriage_wiper_colour);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module rail_screws(type, length, thickness, screws = 100) { //! Place screws in the rail
|
module rail_screws(type, length, thickness, screws = 100) { //! Place screws in the rail
|
||||||
@@ -187,6 +193,6 @@ module rail_screws(type, length, thickness, screws = 100) { //! Place screws in
|
|||||||
screw(end_screw, end_screw_len);
|
screw(end_screw, end_screw_len);
|
||||||
|
|
||||||
translate_z(rail_screw_height(type, screw))
|
translate_z(rail_screw_height(type, screw))
|
||||||
rail_hole_positions(type, length, index_screws, screws)
|
rail_hole_positions(type, length, index_screws, min(screws, rail_holes(type, length)) - 2 * index_screws)
|
||||||
screw(screw, screw_len);
|
screw(screw, screw_len);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user