Made more realistic and added a test.

This commit is contained in:
Chris Palmer 2020-02-23 14:28:39 +00:00
parent 3d8a9ec8aa
commit 1e5e5860e1
4 changed files with 24 additions and 7 deletions

View File

@ -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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -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();

View File

@ -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);
}
}