2019-06-08 22:10:47 +01:00
//
// NopSCADlib Copyright Chris Palmer 2018
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
2024-04-21 10:26:28 +01:00
//! 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.
2019-06-08 22:10:47 +01:00
//
2020-02-29 17:52:36 +00:00
include < ../utils/core/core.scad >
2020-11-13 09:35:56 +00:00
include < ../utils/tube.scad >
2024-04-21 10:26:28 +01:00
include < ../utils/sweep.scad >
2019-06-08 22:10:47 +01:00
function tubing_material ( type ) = type [ 1 ] ; //! Material description
function tubing_od ( type ) = type [ 2 ] ; //! Outside diameter
function tubing_id ( type ) = type [ 3 ] ; //! Inside diameter
function tubing_colour ( type ) = type [ 4 ] ; //! Colour
2020-08-13 11:56:53 +01:00
function tubing_or ( type ) = tubing_od ( type ) / 2 ; //! Outside radius
2022-01-10 23:20:04 +00:00
function tubing_ir ( type ) = tubing_id ( type ) / 2 ; //! Inside radius
2020-08-13 11:56:53 +01:00
2024-04-21 10:26:28 +01:00
module tubing ( type , length = 15 , forced_id = 0 , center = true , path = [ ] ) { //! Draw specified tubing with optional forced internal diameter and optional path.
2019-06-08 22:10:47 +01:00
original_od = tubing_od ( type ) ;
original_id = tubing_id ( type ) ;
id = forced_id ? forced_id : original_id ;
od = original_od + id - original_id ;
2024-04-21 10:26:28 +01:00
length = path ? round ( path_length ( path ) ) : length ;
2019-06-08 22:10:47 +01:00
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
vitamin ( str ( "tubing(" , type [ 0 ] , arg ( length , 15 ) , "): " , tubing_material ( type ) , " OD " , original_od , "mm ID " , original_id , "mm x " , length , "mm" ) ) ;
2020-11-13 09:35:56 +00:00
if ( tubing_material ( type ) = = "Carbon fiber" )
2020-11-13 19:27:02 +00:00
woven_tube ( od / 2 , id / 2 , center = center , length , colour = tubing_colour ( type ) ) ;
2020-11-13 09:35:56 +00:00
else
color ( tubing_colour ( type ) )
2024-04-21 10:26:28 +01:00
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 ) ;
}
2019-06-08 22:10:47 +01:00
}