Programming + 3D printing = bliss

Programming + 3D printing = bliss

I just wrote my first program using OpenSCAD. It's a free tool for writing code that generates 3D models. It's very powerful and I wanted to give it a try.

I decided to create a "maker coin" (something that Angus on Maker's Muse does to test filament) with my cerkit logo on it.

Here's the code I created:

include <cerkit-logo.scad>;
translate([0,0,-175]){
	difference(){
		union(){
			// maker coin
			difference() {
				for (i = [10:60]) {
					assign (angle = i*360/8, distance = i*3) {
						rotate(angle, [0, 0, 1])
							translate( [0, 0, distance/3] ) minkowski() {
								cube([distance,distance,distance/3]);
								// rounded corners
								cylinder(h=distance, r=distance/9);
							
							}
					}	
				}
				
				// hollow out the insides of the blocks to make room for the cerkit logo
				translate([0,0,0]){
					cylinder(r=175, h = 300);
				}			
			}
			
			// add the cerkit logo and border
			translate([0,0, 125]) {
				difference(){
					// create a border around the cerkit logo
					translate([0,0, 100]){
						cylinder(r=180, h = 175, center = true);
					}
					translate([0,0,100]){
						cerkit_logo(100);
					}
				}
			}
		}
		
		// get rid of bottom
		translate([0,0,75]){
			cube([600,600,200], center = true);
		}
	}	
}

Here's what the maker coin looks like in Tinkercad:

Revision 3 of my maker coin

I developed an earlier version, but I didn't like it. I decided to give it a black wash to bring out the details:

Revision 2 of my maker coin (rev 1 was too terrible to print)

This was revision 2. It required a lot of post-processing in Tinkercad to get it right. It was upside down, it was too tall, and the cylinder that has the logo in it extended too far up.

On my third revision, I was devoted to getting it 100% correct in the code so it would require only minor post-processing (scaling it to 7.5%). I feel pretty good about the results.

Here is the final revision 3:

Revision 3 printed
Painted and backlit

Update: I decided to flatten out the coin and create revision 4.

Revision 4 - with a flattened structure and a border around the edge
Revision 4 as printed by my Ender 3 Pro 3D printer

Here is the code for revision 4:

// cerkit maker coin (amulet)
// https://cerkit.com/2018/12/26/programming-3d-printing-bliss/
// revision 4.4
include <cerkit-logo.scad>;

amuletHeight = 50;
pointCount = 9;
pointRadiusMultiplier = 3;
pointSize = 200;
pointBorder = 30;


difference(){
	union(){
		difference() {
			amulet(pointCount, amuletHeight, pointRadiusMultiplier, pointSize);
			translate([0, 0, amuletHeight * 1.5]) {
				amulet(pointCount, amuletHeight + 1 * 0.15, pointRadiusMultiplier, pointSize - pointBorder);
			}		
		}
		
		
		// add the cerkit logo and border
		translate([0, 0, amuletHeight]) {
			difference(){
				// create a border around the cerkit logo
				translate([0, 0, amuletHeight - 25]){
					cylinder(r = 180, h = amuletHeight + 1 * 0.15, center = true);
				}
				
				// draw the logo
				translate([-10, 0, amuletHeight - 25]){
					cerkit_logo(amuletHeight + 1 * 0.15);
				}
			}
		}
	}
}	

// Draws the amulet
module amulet(pointCount, h, radiusMultiplier, cubeXY)
{
	for (i = [1:pointCount]) {
		angle = i * 360 / pointCount;
		edgeRadius = pointCount * radiusMultiplier;
		rotate(angle, [0, 0, 1]) {
			minkowski() {
				cube([cubeXY, cubeXY, h]);
				// rounded corners
				cylinder(h = h, r = edgeRadius);
			}
		}					
	}
}

You can download OpenSCAD here.

I used the Inkscape to OpenSCAD Extension from Thingiverse to convert my logo to code that I can use in my maker coin program.

I also used the Notepad++ OpenSCAD language plugin so I could edit OpenSCAD code in notepad++. This was a huge boost to productivity as I use Notepad++ at work and at home all the time.