Advertisement
Guest User

OpenSCAD hole array

a guest
Jul 24th, 2016
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. use <tyler.scad>;
  2.  
  3. inch=25.4;
  4. dx=80;//2*inch;
  5. dy=80;//2*inch;
  6. dia = 9;
  7.  
  8. sx=500;
  9. sy=500;
  10.  
  11. nx=ceil(sx/dx);
  12. ny=ceil(sy/dy);
  13.  
  14. occ_x = dx*(nx-1);
  15. occ_y = dy*(ny-1);
  16.  
  17. off_x = (sx-occ_x)/2;
  18. off_y = (sy-occ_y)/2;
  19.  
  20. echo("x in ",off_x,occ_x+off_x, "span:", occ_x,"nx=",nx);
  21. echo("y in ",off_y,occ_y+off_y, "span:", occ_y,"ny=",ny);
  22. echo("#holes:",nx*ny);
  23.  
  24. $fn=32;
  25.  
  26. module T(c) { if (len(c)==undef) translate([0,0,c]) children(); else translate(c) children(); }
  27.  
  28. for (i=[0:nx-1]) for (j=[0:ny-1]) {
  29. x = off_x+dx*i;
  30. y = off_y+dy*j;
  31. T([x,y]) {
  32. circle(d=dia);
  33. //arc(dia/2, a1=-45,a2=-45+90);
  34. //arc(dia/2, a1=-45+180,a2=-45+90+180);
  35. }
  36. #T([x,y]) square([0,5]);
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement