From bd4f7b155bc532caa9670cb7e6b292e1d0a4d469 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Fri, 8 Jan 2021 11:33:17 +0000 Subject: [PATCH 1/2] Conditionally rendered pulleys to speed up drawing. --- vitamins/pulley.scad | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/vitamins/pulley.scad b/vitamins/pulley.scad index e3618f1..504b183 100644 --- a/vitamins/pulley.scad +++ b/vitamins/pulley.scad @@ -108,24 +108,26 @@ module pulley(type) { //! Draw a pulley cylinder(r = screw_radius(pulley_screw(type)), h = 100); } - color("silver") { - render() difference() { - rotate_extrude() translate([r1, 0]) { - if(hl) - square([pulley_hub_dia(type) / 2 - r1, hl]); + color(silver) { + render_if(pulley_screw_z(type) < hl) + difference() { + rotate_extrude() translate([r1, 0]) { + if(hl) + square([pulley_hub_dia(type) / 2 - r1, hl]); - for(z = [pulley_hub_length(type), hl + ft + w]) - translate([0, z]) - square([pulley_flange_dia(type) / 2 - r1, ft]); + for(z = [pulley_hub_length(type), hl + ft + w]) + translate([0, z]) + square([pulley_flange_dia(type) / 2 - r1, ft]); + } + if(pulley_screw_z(type) < hl) + screw_holes(); } - if(pulley_screw_z(type) < hl) - screw_holes(); - } - render() difference() { // T5 pulleys have screw through the teeth - core(); + render_if(pulley_type(type)[0] == "T") // T5 pulleys have screw through the teeth + difference() { + core(); - if(pulley_screw_z(type) > hl) - screw_holes(); + if(pulley_screw_z(type) > hl) + screw_holes(); } } } From 729891b675b7474416026af2eb2ca02748f83b89 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Sat, 9 Jan 2021 11:13:14 +0000 Subject: [PATCH 2/2] Improved pulley.scad speed. --- vitamins/pulley.scad | 54 +++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/vitamins/pulley.scad b/vitamins/pulley.scad index 504b183..42b88c9 100644 --- a/vitamins/pulley.scad +++ b/vitamins/pulley.scad @@ -64,6 +64,7 @@ module pulley(type) { //! Draw a pulley hl = pulley_hub_length(type); w = pulley_width(type); r1 = pulley_bore(type) / 2; + screw_z = pulley_screw_z(type); or = od / 2; ir = pulley_ir(type); @@ -100,35 +101,42 @@ module pulley(type) { //! Draw a pulley } } - module screw_holes() { - if(pulley_screws(type)) - translate_z(pulley_screw_z(type)) - for(i = [0 : pulley_screws(type) - 1]) - rotate([-90, 0, i * -90]) - cylinder(r = screw_radius(pulley_screw(type)), h = 100); - } + module hub() + rotate_extrude() translate([r1, 0]) { + if(hl) + square([pulley_hub_dia(type) / 2 - r1, hl]); + + for(z = [pulley_hub_length(type), hl + ft + w]) + translate([0, z]) + square([pulley_flange_dia(type) / 2 - r1, ft]); + } + + module screw_holes() + translate_z(screw_z) + for(i = [0 : pulley_screws(type) - 1]) + rotate([-90, 0, i * -90]) + cylinder(r = screw_radius(pulley_screw(type)), h = 100); color(silver) { - render_if(pulley_screw_z(type) < hl) - difference() { - rotate_extrude() translate([r1, 0]) { - if(hl) - square([pulley_hub_dia(type) / 2 - r1, hl]); + if(screw_z && screw_z < hl) + render() + difference() { + hub(); - for(z = [pulley_hub_length(type), hl + ft + w]) - translate([0, z]) - square([pulley_flange_dia(type) / 2 - r1, ft]); + screw_holes(); } - if(pulley_screw_z(type) < hl) - screw_holes(); - } - render_if(pulley_type(type)[0] == "T") // T5 pulleys have screw through the teeth - difference() { - core(); + else + hub(); + + if(screw_z && screw_z > hl) // T5 pulleys have screw through the teeth + render() + difference() { + core(); - if(pulley_screw_z(type) > hl) screw_holes(); - } + } + else + core(); } }