diff --git a/readme.md b/readme.md index 6b71004..cb75eaf 100644 --- a/readme.md +++ b/readme.md @@ -4771,7 +4771,7 @@ T-Tracks used in woodworking jigs --- ## Tubings -Tubing and sleeving. The internal diameter can be forced to stretch it over something. +Tubing and sleeving. The internal diameter can be forced to stretch it over something. A path can be specified, otherwise it is just straight with the specified length. [vitamins/tubings.scad](vitamins/tubings.scad) Object definitions. @@ -4796,7 +4796,7 @@ Tubing and sleeving. The internal diameter can be forced to stretch it over some ### Modules | Module | Description | |:--- |:--- | -| `tubing(type, length = 15, forced_id = 0, center = true)` | Draw specified tubing with optional forced internal diameter | +| `tubing(type, length = 15, forced_id = 0, center = true, path = [])` | Draw specified tubing with optional forced internal diameter and optional path. | ![tubings](tests/png/tubings.png) diff --git a/vitamins/tubing.scad b/vitamins/tubing.scad index 6419e6e..e67baf6 100644 --- a/vitamins/tubing.scad +++ b/vitamins/tubing.scad @@ -18,10 +18,11 @@ // // -//! Tubing and sleeving. The internal diameter can be forced to stretch it over something. +//! Tubing and sleeving. The internal diameter can be forced to stretch it over something. A path can be specified, otherwise it is just straight with the specified length. // include <../utils/core/core.scad> include <../utils/tube.scad> +include <../utils/sweep.scad> function tubing_material(type) = type[1]; //! Material description function tubing_od(type) = type[2]; //! Outside diameter @@ -31,11 +32,12 @@ function tubing_colour(type) = type[4]; //! Colour function tubing_or(type) = tubing_od(type) / 2; //! Outside radius function tubing_ir(type) = tubing_id(type) / 2; //! Inside radius -module tubing(type, length = 15, forced_id = 0, center = true) { //! Draw specified tubing with optional forced internal diameter +module tubing(type, length = 15, forced_id = 0, center = true, path = []) { //! Draw specified tubing with optional forced internal diameter and optional path. original_od = tubing_od(type); original_id = tubing_id(type); id = forced_id ? forced_id : original_id; od = original_od + id - original_id; + length = path ? round(path_length(path)) : length; if(tubing_material(type) == "Heatshrink sleeving") vitamin(str("tubing(", type[0], arg(length, 15), "): ", tubing_material(type), " ID ", original_id, "mm x ",length, "mm")); else @@ -45,9 +47,19 @@ module tubing(type, length = 15, forced_id = 0, center = true) { //! Draw specif woven_tube(od / 2, id /2, center = center, length, colour = tubing_colour(type)); else color(tubing_colour(type)) - linear_extrude(length, center = center, convexity = 4) - difference() { - circle(d = od); - circle(d = id); - } + if(path) + render_if(manifold) + difference() { + sweep(path, circle_points(od / 2)); + start = path[0] - eps * unit(path[1] - path[0]); + n = len(path) - 1; + end = path[n] + eps * unit(path[n] - path[n - 1]); + sweep(concat([start], path, [end]), circle_points(id / 2)); + } + else + linear_extrude(length, center = center, convexity = 4) + difference() { + circle(d = od); + circle(d = id); + } }