links_count=3; // [1..20] include_terminal=true; // [true,false] include_screwhole=true; // [true,false] clip_screwhole=2; //export=302;//MODEL_CLIP_A; //export=303;//MODEL_CLIP_B; include use use include use use use use use if (is_model_strict(MODEL_LINKS)) { echo("==============================="); echo(str("Strap length: ", (links_count * get_link_segment_size().x), " mm")); echo("==============================="); } assert(get_link_segment_size().x >= 10, "Link segment is too short."); assert(get_link_segment_size().z >= (get_link_pin_diameter() + get_link_socket_slack().z + 1), "Link segment is too thin."); module link(terminal=false) { $fn=$preview?4:20; module link_joiner() { gap=get_link_socket_roundgap(); segment_size=get_link_segment_size(); arm_size=get_link_joiner_arm_size(); module pin_to_socket_joiner() { joiner_size=[segment_size.x-get_link_socket_size().x+get_link_socket_size().x*0.2, segment_size.y-4, segment_size.z]; difference() { right(joiner_size.x/2 + 4.5) cuboid(joiner_size, fillet=1, edges=EDGES_Z_ALL + EDGES_BOTTOM); right(segment_size.x) scale([1, 2, 1]) pin_socket_area(); } } pin_to_socket_joiner(); } link_connector_pin(); if (terminal) { right(get_link_segment_size().x + 2) zrot(180) link_connector_pin(); } else { link_joiner(); right(get_link_segment_size().x) link_connector_socket(); } } module link_chain(links_count, include_terminal=true) { for (i = [0:links_count-1]) { terminal=(i==links_count-1) && include_terminal; right(i*get_link_segment_size().x) link(terminal=terminal); } } module clip() { $fn=$preview?4:20; socket_size=get_link_socket_size(); clip_size=get_link_clip_size(); pin_diam=get_link_pin_diameter(); slot_slack=get_link_socket_slack(); size=[clip_size.x+socket_size.x, clip_size.y, clip_size.z]; slot_size=[clip_size.x+slot_slack.x, size.y+1, pin_diam+slot_slack.z]; entry_size=[slot_size.x, clip_size.y+1, clip_size.z]; entry_pos=[0, 0, 1.5]; module socket_area() { $fn=$preview? 10 : 20; xrot(90) down(size.y/2) cylinder(d=size.z, h=size.y); } module socket_cutout() { $fn=$preview? 10 : 20; xrot(90) down(slot_size.y/2) cylinder(d=slot_size.z, h=slot_size.y); } module cover() { translate(entry_pos) cube(entry_size, center=true); } module joiner(groove) { slack=groove?0.2:0; joiner_size=[entry_size.x-6+slack, entry_size.y-6+slack, entry_size.z-3+slack]; joiner_pos=[entry_pos.x, entry_pos.y, entry_pos.z - entry_size.z/2 + joiner_size.z/2]; difference() { translate(joiner_pos) cube(joiner_size, center=true); screw_cutout(); } } module screw_cutout() { if (include_screwhole) down(clip_size.z/2) screwhole(d=clip_screwhole, h=clip_size.z); } module model() { difference() { union() { right(clip_size.x/2) socket_area(); left(clip_size.x/2) socket_area(); cube(clip_size, center=true); } right(clip_size.x/2) socket_cutout(); left(clip_size.x/2) socket_cutout(); screw_cutout(); } } left(socket_size.x/2) { if (is_model(MODEL_CLIP_A)) { difference() { model(); cover(); } joiner(groove=false); } if (is_model(MODEL_CLIP_B)) { difference() { intersection() { model(); cover(); } joiner(groove=true); } } } } module clip_ratcheting(ratchet_length=28) { $fn=$preview?4:20; socket_size=get_link_socket_size(); clip_size=get_link_clip_size(); pin_diam=get_link_pin_diameter(); slot_slack=get_link_socket_slack(); size=[clip_size.x+socket_size.x, clip_size.y, clip_size.z]; slot_size=[clip_size.x+slot_slack.x + 0.2, size.y+1, pin_diam+slot_slack.z]; entry_size=[slot_size.x-5, clip_size.y+1, clip_size.z]; connector_size=[25, 0, 0]; module hookRight() { right(connector_size.x/2) zrot(180) link_connector_pin(); } module hookLeft() { left(connector_size.x/2) link_connector_pin(); } wall=2; tooth_size=[4, 3, 3]; module tooth() { s=[tooth_size.x, tooth_size.z, tooth_size.y]; up(tooth_size.z/2) xrot(-90) right_triangle(s); } module teethFwd() { tooth_count = ratchet_length/tooth_size.x; fwd((clip_size.y-wall*2)/2) right(ratchet_length/2) { for (i=[1:tooth_count]) { left(i*tooth_size.x) tooth(); } cap_size=[ratchet_length, tooth_size.y, 1]; up(tooth_size.z/2 + cap_size.z/2) left(cap_size.x/2) back(tooth_size.y/2) { difference() { cube(cap_size, center=true); translate([0.1, 0.1, 0]) back(tooth_size.y/2) right(ratchet_length/2) zrot(180) tooth(); } } } } module teethBack() { scale([1, -1, 1]) teethFwd(); } module ratchetLeft() { right(ratchet_length/2) { difference() { cube([ratchet_length, clip_size.y, clip_size.z], center=true); up(wall/2) cube([ratchet_length, clip_size.y-wall*2, clip_size.z], center=true); right(ratchet_length/2+1) { slideRailGuide(groove=true); scale([1,-1,1]) slideRailGuide(groove=true); } } teethFwd(); teethBack(); } } ratchet_tooth_count=2; ratchet_wall=2.5; ratchet_slack=0.3; rail_slack=0.2; ratchet_tooth_scale_z=0.8; module ratchetTeethFront() { module ratchetButton() { size=[8,wall*4,4]; up(size.z+1) fwd(wall*2 - ratchet_wall) cuboid(size, fillet=1, edges=EDGES_FRONT); up(2) back(ratchet_wall/2) cube([size.x, ratchet_wall, tooth_size.z*ratchet_tooth_scale_z + size.z], center=true); } fwd((clip_size.y-wall*2)/2 - tooth_size.y - ratchet_slack) left(ratchet_length) { for (i=[0:ratchet_tooth_count-1]) { right(i*tooth_size.x) scale([-1,-1*(1-i/5),ratchet_tooth_scale_z]) tooth(); } ratchetButton(); } module ratchetWall() { up(tooth_size.z/2) left(ratchet_length/2 + wall - wall/2) fwd(clip_size.y/2-wall-tooth_size.y-ratchet_wall/2 - ratchet_slack) down(wall/2+0.5) cube([ratchet_length + wall, ratchet_wall, tooth_size.z*ratchet_tooth_scale_z], center=true); } ratchetWall(); } module ratchetTeethBack() { scale([1,-1,1]) ratchetTeethFront(); } module ratchetRight() { left(wall) cube([wall*2, clip_size.y + rail_slack*2, clip_size.z], center=true); ratchetTeethFront(); ratchetTeethBack(); } module slideRailGuide(groove) { size=[ratchet_length, wall, wall]; fwd(clip_size.y/2 + rail_slack) left(size.x/2) scale(groove?1.5:1) cuboid(size, fillet=0.5); } module slideRailLeft() { size=[ratchet_length, clip_size.y/2 - ratchet_wall*2 - wall/2 - ratchet_slack - tooth_size.y, clip_size.z]; right(size.x/2) cube(size, center=true); } module slideRailRight() { size=[ratchet_length + 3, wall*1.5, clip_size.z]; module railFront() { fwd(clip_size.y/2 + size.y/2 + rail_slack) left(size.x/2) cuboid(size, fillet=1, edges=EDGES_FRONT); slideRailGuide(groove=false); } module railBack() { scale([1, -1, 1]) railFront(); } railFront(); railBack(); } right(size.x + connector_size.x - 2) { left(2) if (is_model(MODEL_CLIP_RATCHETING_A) || is_model(MODEL_CLIP_RATCHETING)) { left(ratchet_length + wall + 1) { hookLeft(); left(0.1) { ratchetLeft(); slideRailLeft(); } } } right(is_model(MODEL_DEMO) ? ratchet_length + 5 : 0) if (is_model(MODEL_CLIP_RATCHETING_B) || is_model(MODEL_CLIP_RATCHETING)) { ratchetRight(); hookRight(); slideRailRight(); } } } // === Export === if (is_model(MODEL_DEMO)) { foreach_platform_strap_connector() { zrot(180) down(get_link_segment_size().z/2) { link_chain(links_count, include_terminal=include_terminal); /*right(links_count * get_link_segment_size().x + get_link_clip_size().x) { clip(); right(get_link_clip_size().x) clip_ratcheting(); }*/ } } } else { if (is_model(MODEL_CLIP_A) || is_model(MODEL_CLIP_B)) { left(get_link_clip_size().x) clip(); } if (is_model(MODEL_CLIP_RATCHETING) || is_model(MODEL_CLIP_RATCHETING_A) || is_model(MODEL_CLIP_RATCHETING_B)) { left(get_link_clip_size().x * 2 + 3) clip_ratcheting(); } if (is_model(MODEL_LINKS)) for (i = [0:links_count-1]) { terminal=(i==links_count-1) && include_terminal; right(i*get_link_segment_size().x) link(terminal=terminal); } }