//this module creates a 3D line. Essentially it is an elongated 3D polygon module line3D(p1, p2, thickness, fn = 24) { $fn = fn; //hull is a 3D transformation in OpenSCAD which combines multiple modules into one nice cover. https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#hull hull() { translate(p1) sphere(thickness / 2); translate(p2) sphere(thickness / 2); } } //this module utilizes 3D line iterative to generate a locus of 3D lines which accumulatively gives the resemblance of a 3D Spiral. module polyline3D(points, thickness, fn) { module polyline3D_inner(points, index) { if(index < len(points)) { line3D(points[index - 1], points[index], thickness, fn); polyline3D_inner(points, index + 1); } } polyline3D_inner(points, 1); } //Spiral parameters, i.e. thickness, radius, how many layers r = 8; h = 20; fa = 15; circles = 1; //locus of points which are used in Hull transformation to create a 3D line using the line3D module mentioned above points = [ for(a = [0:fa:360 * circles]) [r * cos(a), r * sin(a), h / (360 / fa) * (a / fa)] ]; difference(){//subtracting spiral from a cylinder using difference operator cylinder(20,10 ,10); //Solid sylinder polyline3D(points, 3, 3); // 3D spiral }