I’ll first show you the simplicity of the code with this very simple design of a push pin for the plastic inner fender for a car. The parametric nature of openSCAD allows me to return to the code and change a variable easily and with great precision.
// Push Rivet for Car
// Mark Cain
// August 22, 2020
// Revision 0.3 //
// Revision 0.2 // measurements in mm height=16, cone_base=14, cone_tip=6
// Revision 0.1 // measurements in mm height=20, cone_base=15, cone_tip=5
cone_base = 14;
cone_height = 16;
cone_tip = 6;
ring_elevation = 6;
ring_height = 4;
connector_height =10;
rotate([0, 0 , 0]){
difference() {
union() { // beginning of the visible union
cylinder(h=cone_height, d1=cone_base, d2=cone_tip);
}; // end of the visible union
union() { // beginning of the cut union
translate([0, 0, ring_elevation])
cylinder(h=ring_height, d=cone_base);
}; // end of the cut union
}; // end of project difference
// inside column for the ring's center
cylinder(h=connector_height, d=cone_tip+2);
}; // end of rotate
// variables
$fn=360;