/************************************************************************************* * * $RCSfile: Parametric\040Pipe\040Adapter.scad,v $ * $Date: 2014/04/15 22:59:05 $ * $Revision: 1.2 $ * * Parametric Pipe Adapter * ************************************************************************************* * * THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT * HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * IT IS NOT PERMITTED TO MODIFY THIS COMMENT BLOCK. * * (c)2014, Claude "Tryphon" Theroux, Montreal, Quebec, Canada * ************************************************************************************/ //////////////////////////////////////////////////////////////////////////////// // // User's Parameters // // Lower pipe interior diameter in millimeters. upperPipeDiameter < lowerPipeDiameter lowerPipeDiameter = 39.65 + 1; // Upper pipe interior diameter in millimeters. upperPipeDiameter < lowerPipeDiameter upperPipeDiameter = 15.875 + 0.5; // Tickness of the reducer portion in millimeters adapterTickness = 3; // Adapter total height in millimeters adapterHeight = 80; //////////////////////////////////////////////////////////////////////////////// // // Derived values // reducerAngle = 45; lowerPipeRadius = lowerPipeDiameter / 2; upperPipeRadius = upperPipeDiameter / 2; reducerHeight = tan(reducerAngle) * (lowerPipeRadius - upperPipeRadius); pipeCouplersHeight = (adapterHeight - reducerHeight) / 2; radiusDelta = adapterTickness / sin(reducerAngle); if( pipeCouplersHeight < 0 ) { displayError("Total height too small", "adapterHeight", adapterHeight); } //////////////////////////////////////////////////////////////////////////////// // // Code // module displayError(pMessage, pValueName, pValue) { echo("*** ERROR *** ERROR *** ERROR *** ERROR *** ERROR *** ERROR *** ERROR"); echo("***"); echo(str("*** ERROR: ", pMessage, ": ", pValueName, "=", pValue)); echo("***"); echo("*** ERROR *** ERROR *** ERROR *** ERROR *** ERROR *** ERROR *** ERROR"); } module reducer() { difference() { cylinder(h = reducerHeight, r1 = lowerPipeRadius + radiusDelta, r2 = upperPipeRadius + radiusDelta, center = false, $fn = 90); cylinder(h = reducerHeight, r1 = lowerPipeRadius, r2 = upperPipeRadius, center = false, $fn = 90); } } module lowerPipe() { difference() { cylinder(h = pipeCouplersHeight, r1 = lowerPipeRadius + radiusDelta, r2 = lowerPipeRadius + radiusDelta, center = false, $fn = 90); cylinder(h = pipeCouplersHeight, r1 = lowerPipeRadius, r2 = lowerPipeRadius, center = false, $fn = 90); } } module upperPipe() { difference() { cylinder(h = pipeCouplersHeight, r1 = upperPipeRadius + radiusDelta, r2 = upperPipeRadius + radiusDelta, center = false, $fn = 90); cylinder(h = pipeCouplersHeight, r1 = upperPipeRadius, r2 = upperPipeRadius, center = false, $fn = 90); } } if( reducerAngle >= 45 ) { translate([0, 0, -pipeCouplersHeight]) lowerPipe(); reducer(); translate([0, 0, reducerHeight]) upperPipe(); } else { displayError("Reducer angle too low", "reducerAngle", reducerAngle); }