diff --git a/readme.md b/readme.md index d8fded4..d6c116a 100644 --- a/readme.md +++ b/readme.md @@ -2562,7 +2562,7 @@ Filament spool models ### Modules | Module | Description | |:--- |:--- | -| ```spool(type)``` | Draw specified spool | +| ```spool(type, filament_depth = 0, filament_colour = "white", filament_d = 3)``` | Draw specified spool with optional filament | ![spools](tests/png/spools.png) diff --git a/tests/png/spools.png b/tests/png/spools.png index 9d9847f..2adc977 100644 Binary files a/tests/png/spools.png and b/tests/png/spools.png differ diff --git a/tests/spools.scad b/tests/spools.scad index d39c246..7d6ff13 100644 --- a/tests/spools.scad +++ b/tests/spools.scad @@ -23,9 +23,9 @@ use <../utils/layout.scad> include <../vitamins/spools.scad> module spools() - layout([for(s = spools) spool_height(s)], 100) + layout([for(s = spools) spool_height(s)], 100) let(s = spools[$i]) rotate([90, 0, 90]) - spool(spools[$i]); + spool(s, filament_depth = spool_depth(s) / 2, filament_colour = [pp1_colour, pp2_colour, pp3_colour, pp4_colour][$i % 4], filament_d = $i ? 3 : 1.75); if($preview) spools(); diff --git a/vitamins/spool.scad b/vitamins/spool.scad index 56c77e5..19c4c16 100644 --- a/vitamins/spool.scad +++ b/vitamins/spool.scad @@ -33,7 +33,7 @@ function spool_hub_taper(type) = type[8]; //! Diameter at which it tapers do function spool_height(type) = spool_width(type) + 2 * spool_hub_thickness(type); //! Outside width function spool_pitch(type) = spool_width(type) + spool_rim_thickness(type); //! Spacing of the rims -module spool(type, filament_depth = 0, filament_color = "white") { //! Draw specified spool with optional filament +module spool(type, filament_depth = 0, filament_colour = "white", filament_d = 3) { //! Draw specified spool with optional filament vitamin(str("spool(", type[0], "): Filament spool ", spool_diameter(type), " x ", spool_width(type))); h = spool_height(type); @@ -59,7 +59,24 @@ module spool(type, filament_depth = 0, filament_color = "white") { //! Draw spec [r2, h], ]); - if(filament_depth) - color(filament_color) - tube(r5 + filament_depth, r5, spool_width(type)); + if(filament_depth) { + w = spool_width(type); + r = r5 + filament_depth; + color(filament_colour) + if(filament_d) { + n = round(w / filament_d) + 1; + fd = w / n; + rotate_extrude($fn = 180) { + for(i = [0 : n -1]) + translate([r - fd / 2, i * fd - w / 2 + fd / 2]) + circle(d = fd, $fn = 32); + + translate([r5, -w / 2]) + square([filament_depth - fd / 2, w]); + } + } + + else + tube(r, r5, w, $fn = 180); + } }