Using OpenSCAD to edit STL files

Here's a simple example of how to use OpenSCAD to edit a pre-existing STL file.  This is useful if you want to add or subtract areas to the existing file.  

OpenSCAD is an open source CAD program that allows users to programmatically build up models using basic geometries.  The below example is based off of the part 

Download OpenSCAD from   (It's free)

Download the STL file that you want to edit. For this example I used

My mod here shows how to make the hole in the center of the gear larger so it fits a different type of potentiometer.  (Measurements are in millimeters)


/* Create a model of the potentiometer shaft */

module actuatorHole() {

// Some measurements

x = 9.5;

r2 = 4;

h = 10;

r = 3.1;

rotate([0,0,45]) {

difference() {

cylinder(h,r,r, $fn=50);

translate([-r-.2,-r-.2,h/2]) {

rotate([0,0,-45]) {

cube([r*2,r*2,h], center=true);





translate([.1,-.1,-x]) {

cylinder(h,r2,r2, $fn=50);




/* the original stl file */

module orig() {

translate([0,0,0]) {





/* The main script starts here

Load the original model,

and subtract away the model of the potentiometer shaft */


difference() {