Pipe Fitting Generator
OpenSCAD script for generating pipe fittings parametrically.
Overview
Section titled “Overview”It generates a pipe coupling: a fitting with an external thread at each end, and for each end a nut and a tapered gasket, which the nut compresses onto the pipe. The threads come from threadlib’s thread tables.
Note: By using this library, you accept full personal responsibility for its use and any resulting outcomes, and irrevocably agree to the terms outlined in the legal disclaimer. In short, you are agreeing to assume all risks associated with its use.
Dependencies
Section titled “Dependencies”- OpenSCAD software.
threadlib, release 0.5. With the code atarchive/table-3, versions 0.3 and later reproduce the tested fittings and nuts, but which version generated them is not recorded.- The three libraries
threadlibitself needs:scad-utils,list-comprehension-demosandthread_profile.scad.
Installation
Section titled “Installation”- Ensure OpenSCAD is installed on your system.
- Open your libraries folder from OpenSCAD with File > Show Library Folder.
- Download all of the libraries above and this repository into it, so that it looks like this. A downloaded zip adds a suffix such as
-mainto the folder name, which you need to remove.
libraries|-- list-comprehension-demos/|-- pipe-fitting-scad/|-- scad-utils/|-- thread_profile.scad`-- threadlib/If threadlib is missing, pfDesigner.scad stops at the assertion No thread has a support diameter from ... mm. Change gasket_thickness_lower or gasket_thickness_upper. The message points at the gasket thicknesses, but the cause is that OpenSCAD could not find threadlib. examples/base_example.scad fails differently without it, reporting that its thread “is too small for this pipe: its bore radius is undef mm”.
If one of the three libraries threadlib needs is missing, OpenSCAD can still export a fitting with no threads and report success. Check the console for Can't open library warnings, and check that the threads are there before printing.
Creating your Fitting
Section titled “Creating your Fitting”Open pfDesigner.scad in OpenSCAD and set its parameters, listed in the docs, in the Customizer. The Customizer loads the presets in pfDesigner.json: design default values, 10mm_test and 20mm_test.
- Set
input_diato the pipe’s outside diameter. The script lists every external thread inthreadlibwhose support diameter is frominput_dia + gasket_thickness_lower / 2toinput_dia + gasket_thickness_upper / 2. Widen that range if it finds none. - Set
exporttofalseto show every candidate thread side by side, each with its gasket and labelled[i]: <thread>. - The console echoes
SHOWING[i/N]:and the selected thread, whereNis the number of candidates. SetselectedThreadto theiyou want, from 0 toN - 1. - Set
exporttotrueandselectedParttofitting,nut,gasket,closed_nut,flat_gasketorall(the fitting, nut and gasket), then render and export.
The script stops with an error if the selected thread’s bore cannot clear the pipe, if tol_gasket is not less than tol_pipe, or if gasket_extra_length is not more than the thread pitch.
examples/base_example.scad calls the modules in pipeFitting.scad from another file, through use <pipe-fitting-scad/pipeFitting.scad>, with a fixed thread (UNC-7/8-ext). It places the fitting, nut and gasket in their assembled positions, with an optional cross-section.
Manufacturing your Fitting
Section titled “Manufacturing your Fitting”The tested fittings and nuts were printed in PLA, PETG and ASA, and the gaskets in TPE 85 Shore A, using 0.4 mm nozzles and PrusaSlicer 2.8.0. The STLs, slicer profiles and G-code are on OSF. Print settings are in the paper’s Table 3, though some differ from the OSF G-code.
Performance Testing
Section titled “Performance Testing”These results are not a guarantee of safety or a pressure rating. Test your own parts, and take proper precautions when working with pressurised water.
The paper tested printed couplings with water pressure, raised in steps of 0.345 MPa (50 psi) held for 180 s each, until the coupling leaked or lost pressure. The highest pressures reached were:
| Coupling | Highest pressure | Torque |
|---|---|---|
| 10 mm, PETG body and nuts | 4.551 MPa (660 psi) | Highest without cracking: 12.5 Nm |
| 10 mm, ASA | 2.758 MPa (400 psi) | Highest without cracking: 15 Nm |
| 10 mm, PLA | 2.275 MPa (330 psi) | Highest without cracking: 7.5 Nm |
| 20 mm, PETG | 2.392 MPa (347 psi) | Reached at 17.5 Nm |
All gaskets were TPE 85 Shore A. The figures were read by hand from an analog gauge with an accuracy of +/-0.138 MPa (+/-20 psi). That is the gauge’s accuracy, not the spread between parts. The readings for each test were not kept, so the number of tests behind each figure is not known.
The far end of each test coupling was closed with a capped nut and a flat 2 mm disc gasket, rather than a second pipe, so each test loaded one tapered gasket sealing on a pipe. Which end leaked was not recorded. Set selectedPart to closed_nut or flat_gasket to generate the capped nut and disc gasket.
These are the highest pressures held for a few minutes by these particular parts. They are not working pressures. The tests did not cover pressure held for long periods, repeated pressure cycles, water temperature, ageing, or repeated assembly. The 20 mm coupling reached about half the pressure of the 10 mm one, so results at one size do not carry over to another. The paper compares 4.551 MPa with a 0.552 MPa residential limit, which is about eight times higher. That ratio is not a safety factor.
How it Works
Section titled “How it Works”
The paper’s flowchart: pfDesigner.scad passes the parameters to pipeFitting.scad, which builds the parts from the modules in adaptersMod/, and the fitting, gasket and cap nut are exported as meshes.
Publication Archive
Section titled “Publication Archive”The paper’s Data Availability Statement refers to an archived jmmp branch. That branch is now the tag archive/jmmp, at the same commit (75c1e87).
The values in the paper’s Table 3 apply to the tag archive/table-3 (7a59d5b). The two rows Table 3 labels middle_length are the lower_length and mid_height inputs at that tag. Later code replaced those inputs with middle_length and transition_length and changed what they drive, so Table 3’s numbers do not carry over. At the tag, Table 3’s values reproduce the OSF fittings, nuts and 20 mm gasket. The OSF 10 mm gasket STL is 1 mm longer than Table 3’s value gives.
The 10mm_test and 20mm_test presets keep the tested inputs. The current code keeps the fitting’s full wall thickness at the threaded tip, where the tested fittings thinned to an edge, so its fittings differ slightly from the tested ones. Use the tag for the exact tested geometry.
Contributing
Section titled “Contributing”Issues and pull requests are welcome.
License
Section titled “License”Copyright (C) 2023-2024 Cameron K. Brooks and FAST Lab, Western University.
Licensed under the GNU General Public License, version 3 only (GPL-3.0-only). See the LICENSE file, and LICENSING.md for what applies where and why.
The files in adaptersMod/ are adapted from Makrokaba’s generator (see below). Its 2020 versions are under the BSD 3-Clause terms kept in those files’ headers.
Acknowledgement
Section titled “Acknowledgement”Cameron Brooks originally created this in the FAST Research Group. It was published in:
Taherzadeh Fini, A.; Brooks, C.K.; Romani, A.; Straatman, A.G.; Pearce, J.M. Parametric Design of Easy-Connect Pipe Fitting Components Using Open-Source CAD and Fabrication Using 3D Printing. J. Manuf. Mater. Process. 2025, 9, 65. https://doi.org/10.3390/jmmp9020065
The design is certified by the Open Source Hardware Association as CA000069.
This design uses threadlib by Adrian Schlatter and builds on Makrokaba’s universal thread and pipe joint generator.
