1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-08 22:21:25 +02:00

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

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