From 03c97e8b6af02a928b4eb312e0cdcad8a094891b Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Sat, 11 Jan 2020 14:50:10 +0000 Subject: [PATCH 1/2] Changed rail carriage coloring to be green with red endpiece to match common form. --- vitamins/rail.scad | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/vitamins/rail.scad b/vitamins/rail.scad index de75c28..c202b39 100644 --- a/vitamins/rail.scad +++ b/vitamins/rail.scad @@ -100,19 +100,30 @@ module carriage(type, rail) { //! Draw the specified carriage carriage_hole_positions(type) circle(screw_pilot_hole(screw)); } - } - color(grey20) - for(end = [-1, 1]) - translate([end * (block_l / 2 + end_l / 2), 0]) - rotate([90, 0, 90]) - linear_extrude(height = end_l, center = true) - difference() { - translate([-end_w / 2, carriage_clearance(type)]) - square([end_w, end_h]); - cutout(); - } + module carriage_end(type, end_w, end_h, end_l) { + red_length = 0.5; + color("red") translate_z(-end_l/2) linear_extrude(red_length) + difference() { + translate([-end_w/2, carriage_clearance(type)]) + square([end_w, end_h]); + cutout(); + } + color("green") translate_z(red_length-end_l/2) linear_extrude(end_l-red_length) + difference() { + translate([-end_w/2, carriage_clearance(type)]) + square([end_w, end_h]); + cutout(); + } + } + + translate([-(block_l+end_l)/2,0,0]) + rotate([90, 0, 90]) + carriage_end(type, end_w, end_h, end_l); + translate([(block_l+end_l)/2,0,0]) + rotate([90, 0, -90]) + carriage_end(type, end_w, end_h, end_l); } module rail(type, length) { //! Draw the specified rail From 75747687d9b2d0318400308cc5349cd25624b681 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Sun, 12 Jan 2020 10:20:10 +0000 Subject: [PATCH 2/2] Parameterised coloring of linear rail carriage. --- tests/rails.scad | 2 +- vitamins/rail.scad | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/rails.scad b/tests/rails.scad index f91b950..2a72118 100644 --- a/tests/rails.scad +++ b/tests/rails.scad @@ -34,7 +34,7 @@ module rails() nut = screw_nut(screw); washer = screw_washer(screw); - rail_assembly(rail, length, rail_travel(rail, length) / 2); + rail_assembly(rail, length, rail_travel(rail, length) / 2, $i<2 ? grey20 : "green", $i<2 ? grey20 : "red"); rail_screws(rail, length, sheet + nut_thickness(nut, true) + washer_thickness(washer)); diff --git a/vitamins/rail.scad b/vitamins/rail.scad index c202b39..db42e4a 100644 --- a/vitamins/rail.scad +++ b/vitamins/rail.scad @@ -65,7 +65,7 @@ module carriage_hole_positions(type) { //! Position children over screw holes children(); } -module carriage(type, rail) { //! Draw the specified carriage +module carriage(type, rail, end_color = grey20, wiper_color = grey20) { //! Draw the specified carriage total_l = carriage_length(type); block_l = carriage_block_length(type); block_w = carriage_width(type); @@ -103,14 +103,14 @@ module carriage(type, rail) { //! Draw the specified carriage } module carriage_end(type, end_w, end_h, end_l) { - red_length = 0.5; - color("red") translate_z(-end_l/2) linear_extrude(red_length) + wiper_length = 0.5; + color(wiper_color) translate_z(-end_l/2) linear_extrude(wiper_length) difference() { translate([-end_w/2, carriage_clearance(type)]) square([end_w, end_h]); cutout(); } - color("green") translate_z(red_length-end_l/2) linear_extrude(end_l-red_length) + color(end_color) translate_z(wiper_length-end_l/2) linear_extrude(end_l-wiper_length) difference() { translate([-end_w/2, carriage_clearance(type)]) square([end_w, end_h]); @@ -150,11 +150,11 @@ module rail(type, length) { //! Draw the specified rail } } -module rail_assembly(type, length, pos) { //! Rail and carriage assembly +module rail_assembly(type, length, pos, carriage_end_color = grey20, carriage_wiper_color = grey20) { //! Rail and carriage assembly rail(type, length); translate([pos, 0]) - carriage(rail_carriage(type), type); + carriage(rail_carriage(type), type, carriage_end_color, carriage_wiper_color); }