You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
4.7 KiB
OpenSCAD
165 lines
4.7 KiB
OpenSCAD
3 months ago
|
// mathgrrl punch card maker
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////
|
||
|
// parameters
|
||
|
|
||
|
$fn=48; // resolution
|
||
|
|
||
|
rows = 48; // number of pattern rows
|
||
|
cols = 24; // 24 is standard
|
||
|
|
||
|
p = 3.75; // punch diameter
|
||
|
r = p/2; // punch radius
|
||
|
h = 4.5; // horizontal distance between punch centers
|
||
|
v = 5; // vertical distance between punch centers
|
||
|
|
||
|
b = 16; // horizontal card border
|
||
|
c = 11; // vertical card border
|
||
|
|
||
|
width = cols*h+2*b; // card width - should be 140 for 24 punches
|
||
|
height = rows*v+2*c; // card height - should be 322 for 60 rows
|
||
|
|
||
|
gaugerows = 6; // test gauge and enter here
|
||
|
gaugestitches = 5; // test gauge and enter here
|
||
|
|
||
|
x = 1; // allows x in visual punch layout
|
||
|
|
||
|
%color("white") card(width,height); // makes gray background for F5
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////
|
||
|
// punch the BORDER HOLES
|
||
|
|
||
|
edge(width,height);
|
||
|
belt(rows);
|
||
|
loop(rows);
|
||
|
overlap(rows);
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////
|
||
|
// punch a PATTERN (choose one)
|
||
|
|
||
|
// one-line experiments
|
||
|
//punch(offdiagonals(6,rows));
|
||
|
//punch(squares(4,4,rows));
|
||
|
//punch(diagonals(6,10),shift=1,reverse="yes");
|
||
|
|
||
|
// diamonds
|
||
|
//punch(diagonals(6,rows));
|
||
|
//punch(offdiagonals(6,rows));
|
||
|
|
||
|
// uneven diamonds
|
||
|
//punch(diagonals(6,rows));
|
||
|
//punch(offdiagonals(5,rows));
|
||
|
|
||
|
// baby squares
|
||
|
//punch(diagonals(3,rows));
|
||
|
//punch(offdiagonals(3,rows));
|
||
|
|
||
|
// baby square diagonal mixup
|
||
|
//punch(offdiagonals(12,rows));
|
||
|
//punch(offdiagonals(8,rows));
|
||
|
//punch(diagonals(3,rows));
|
||
|
|
||
|
// zipper
|
||
|
//punch(dots(4,1,rows));
|
||
|
//punch(dots(6,4,rows));
|
||
|
//punch(square(4,rows));
|
||
|
punch(fil());
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////
|
||
|
// FUNCTIONS for patterns
|
||
|
include <patterndata.scad>;
|
||
|
function fil(filename) =
|
||
|
datas;
|
||
|
|
||
|
// multiple rows of dots every "size" starting at "shift"
|
||
|
function dots(size,shift,length) =
|
||
|
[ for (j=[length-1:-1:0])
|
||
|
[ for (i=[0:cols-1]) (i+j*(size-shift))%size==0 ? 0 : 1 ] ];
|
||
|
|
||
|
function diagonals(size,length) = // size div by 24
|
||
|
[ for (j=[length-1:-1:0])
|
||
|
[ for (i=[0:cols-1]) (i+j)%size==0 ? 0 : 1 ] ];
|
||
|
|
||
|
function offdiagonals(size,length) = // size div by 24
|
||
|
[ for (j=[length-1:-1:0])
|
||
|
[ for (i=[cols-1:-1:0]) (i+j+1)%size==0 ? 0 : 1 ] ];
|
||
|
|
||
|
function squares(across,high,length) = // across div by 24
|
||
|
[ for (j=[length-1:-1:0])
|
||
|
[ for (i=[0:cols-1]) (j%high==0 || i%across==0) ? 0 : 1 ] ];
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////
|
||
|
// MODULES for patterns
|
||
|
|
||
|
module gauge(col=3,row=4){
|
||
|
linear_extrude(2)
|
||
|
translate([0,c])
|
||
|
scale([1,(h/v)*(gaugestitches/gaugerows)])
|
||
|
translate([0,-c])
|
||
|
children();
|
||
|
}
|
||
|
|
||
|
module punch(pattern,start=0,shift=0,reverse="no"){
|
||
|
|
||
|
// convert to coordinate list
|
||
|
// if/else requires updated OpenSCAD and lc-else setting in preferences
|
||
|
coords = [ for (i=[0:len(pattern[0])-1], j=[0:len(pattern)-1])
|
||
|
if (reverse=="no" && pattern[j][i]==0)
|
||
|
[(i+shift)%cols,len(pattern)-1-j]
|
||
|
else if (reverse=="yes" && pattern[j][i]!=0)
|
||
|
[(i+shift)%cols,len(pattern)-1-j] ];
|
||
|
|
||
|
// place punches according to dimensions
|
||
|
place = [for (i=[0:len(coords)-1])
|
||
|
[h*coords[i][0]+b+h/2,v*coords[i][1]+c+v/2]];
|
||
|
|
||
|
// put the punches on the card
|
||
|
for (i=[0:len(place)-1]) translate(place[i]) color("gray") circle(r);
|
||
|
|
||
|
}
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////
|
||
|
// MODULES for border punches
|
||
|
|
||
|
module belt(rows){
|
||
|
color("lightgreen")
|
||
|
for (j=[-2:rows+1]){
|
||
|
translate([b+h/2-5.5,(c+v/2)+j*v]) circle(r-0.25);
|
||
|
translate([b+h/2+(cols-1)*h+5.5,(c+v/2)+j*v]) circle(r-0.25);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module loop(rows){
|
||
|
color("lightgreen")
|
||
|
for (j=[-1,0,rows/2-1,rows/2]){ // use this for two at top and bottom
|
||
|
//for (j=[-1:rows/2]){ // use this for all the way up and down
|
||
|
translate([b-10.5,c+v+j*2*v]) circle(r);
|
||
|
translate([b+cols*h+10.5,c+(j*2+1)*v]) circle(r);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module overlap(rows){
|
||
|
color("lightgreen")
|
||
|
for (i=[0:cols-1],j=[1,2]){
|
||
|
translate([b+h/2+i*h,c+v/2-j*v]) circle(r);
|
||
|
translate([b+h/2+i*h,c+v/2+(rows-1+j)*v]) circle(r);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////
|
||
|
// MODULES for card
|
||
|
|
||
|
// card outline (inside edge is the desired punch card outline)
|
||
|
module edge(width,height){
|
||
|
extra = 2;
|
||
|
translate([-extra,-extra]) square([width+2*extra,extra]);
|
||
|
translate([-extra,-extra]) square([extra,height+2*extra]);
|
||
|
translate([-extra,height]) square([width+2*extra,extra]);
|
||
|
translate([width,-extra]) square([extra,height+2*extra]);
|
||
|
}
|
||
|
|
||
|
// card shading (display only)
|
||
|
module card(width,height){
|
||
|
linear_extrude(.1) square([width,height]);
|
||
|
}
|