drag_chain_link() now checks it has children when it should.

This commit is contained in:
Chris Palmer 2020-12-01 18:46:14 +00:00
parent f18044915d
commit 42b76ab8d3
2 changed files with 8 additions and 4 deletions

View File

@ -109,7 +109,7 @@ function drag_chain_cam_x(type) = // how far the cam sticks out
) min(sqrt(max(sqr(cam_r) - sqr(r - twall), 0)), r); ) min(sqrt(max(sqr(cam_r) - sqr(r - twall), 0)), r);
module drag_chain_link(type, start = false, end = false) { //! One link of the chain, special case for start and end module drag_chain_link(type, start = false, end = false, check_kids = true) { //! One link of the chain, special case for start and end
stl(str(drag_chain_name(type), "_drag_chain_link", start ? "_start" : end ? "_end" : "")); stl(str(drag_chain_name(type), "_drag_chain_link", start ? "_start" : end ? "_end" : ""));
s = drag_chain_size(type); s = drag_chain_size(type);
@ -222,6 +222,10 @@ module drag_chain_link(type, start = false, end = false) { //! One link of the c
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);
if(check_kids) {
custom = drag_chain_screw_lists(type)[bool2int(end)] == [0, 0, 0, 0];
assert($children == bool2int(custom), str("wrong number of children for ", end ? "end" : "start", " STL customisation: ", $children));
}
children(); children();
} }
} }
@ -278,7 +282,7 @@ module _drag_chain_assembly(type, pos = 0) {
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 < 0 || n == npoints - 1 ? pp3_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, check_kids = false)
let($fasteners = 0) children(); let($fasteners = 0) children();
let($fasteners = 1) children(); let($fasteners = 1) children();
} }

View File

@ -4598,7 +4598,7 @@ to the assembly, for example to add inserts.
| Module | Description | | Module | Description |
|:--- |:--- | |:--- |:--- |
| ```drag_chain_assembly(type, pos = 0)``` | Drag chain assembly | | ```drag_chain_assembly(type, pos = 0)``` | Drag chain assembly |
| ```drag_chain_link(type, start = false, end = false)``` | One link of the chain, special case for start and end | | ```drag_chain_link(type, start = false, end = false, check_kids = true)``` | One link of the chain, special case for start and end |
| ```drag_chain_screw_positions(type, end)``` | Place children at the screw positions, end = 0 for the start, 1 for the end | | ```drag_chain_screw_positions(type, end)``` | Place children at the screw positions, end = 0 for the start, 1 for the end |
| ```screw_lug(screw, h = 0)``` | Create a D shaped lug for a screw | | ```screw_lug(screw, h = 0)``` | Create a D shaped lug for a screw |