// This a generator for laser cut slots of varying type // Author: Roland Grichnik (r.grichnik@googlemail.com) // Date of Creation: 2022-02-12 slot(); //slot(width=10,length=20,flipX=true,cornerCircleDiameter=4,cornerCircleFn=16,chamferLength=2,chamferAngle=60); //simple square slot in positive x with corner cicrles to clear corners completely for assembly. Flipped in X if flag flipX is set. module slot(width=5, length=10, flipX=false, cornerCircleDiameter=1, cornerCircleFn=16, chamferLength=1,chamferAngle=45,smoothingRadius=0.5, smoothingFn=32){ module cornerCircle(){ translate([0,width/2,0]) circle(d=cornerCircleDiameter,$fn=cornerCircleFn); } module chamferPolygon(){ polygon([[length,width/2],[length,width/2+chamferLength],[length-(tan(chamferAngle)*chamferLength),width/2]]); } translate([-length,0,0]) mirror([flipX?1:0,0,0]){ //POS-NEG offset to smmoth internal corners offset(-smoothingRadius,$fn=smoothingFn) offset(delta=smoothingRadius) union(){ translate([0,-width/2,0]) square([length,width]); cornerCircle(); mirror([0,1,0]) cornerCircle(); } chamferPolygon(); mirror([0,1,0]) chamferPolygon(); } }