I posted a first OpenSCAD library - Springs, helicoils, elliptic rings some years ago, but it renders quite slow, as the implementation is based on a programming technique that uses a union of slices along a trajectory - and a large number of unions can take hours in OpenSCAD.
Looking around in thingiverse I found this wonderful idea for a Device to produce PLA springs. Unfortunately I couldn't find any OpenSCAD code in this post. So I dug out my own sweep library and implemented a fast rendering springs and springmaker library. As shown in the pictures section, it supports different spring types: cylindric, conical and flat springs, with and without loops at the ends, and with circular, rectangular or quadratic cross-section. By means of a single difference operation with a cylinder or cone, one gets a spring maker device, just like the mentioned wonderful device.
The library is quite concise, but offers a help module that outputs some help text with the modules' calling conventions and defaults as well as some usage examples to the console. The main module spring() has this parameters and default values:
spring(r=5, R=40, windings=5, H=150, center = true, R1 = undef, start=false, end=false, ends=undef, w = undef, h=undef)
with r, w, h denoting the radius (respectively the width and height) of the cross-section, R and R1 the spring radii, and H the full height. start, end, ends are flags that control whether the code adds a loop at one or both ends of the spring.
The springs.scad library itself refers to the Naca_sweep library explained here. To use it you must download the two *.scad files from the download section into your library folder or current project folder and add a use command for springs.scad at the beginning of your program.
use <springs.scad>; // spring with default values spring();// rect spring spring(R1=100, w = 20, h=10); // quadratic spring reversed spring(w=10, H=100, reverse=true); // negative height, partial windings allowed, ring at start added spring(windings = 2.5, H=-50, center = false, start=true); // conical spring spring(windings = 5.5, R = 30, R1=100, ends=true); // ** error ** this radius causes self intersection spring(r=15); // flat spring spring(H=0, R=100, R1 = 10); // flat rect spring spring(H=0, R=70, R1=10, w=2, h=10); // flat quadratic spring ccw spring(H=0, R=100, R1=10, w=8); // flat quadratic spring cw spring(H=0, R=10, R1=100, w=8); // device to roll your own springs springmaker(r=3, R=20, R1=40, h=50, ends =true);
Naca_sweep.scad | 10.1KB | |
pen_spring.stl | 9.2MB | |
springmaker.stl | 3.3MB | |
springs.scad | 5.1KB | |
springs1.stl | 14.0MB | |
springs2.stl | 9.1MB | |
springs3.stl | 15.3MB | |
springs4.stl | 34.4MB | |
springs5.stl | 948.7KB | |
springs6.stl | 2.3MB | |
springs7.stl | 1.9MB |