connector.scad 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. include <functions.scad>
  2. include <../config/connector.scad>
  3. function connector_size() = [
  4. ];
  5. module connector_shape() {
  6. hole = connector_hole;
  7. holes = connector_holes;
  8. width = connector_width;
  9. rounding = connector_rounding;
  10. holes_space = width / (holes.x + 1);
  11. height = holes_space * (holes.y + 1);
  12. module single_side() {
  13. module holes() {
  14. for (count_x = [-width / 2 : holes_space : width / 2]) {
  15. for (count_y = [-height / 2 : holes_space : height / 2]) {
  16. side_x = abs(count_x) == width / 2;
  17. side_y = abs(count_y) == height / 2;
  18. if (!side_x && !side_y) {
  19. translate([count_x, count_y]) {
  20. circle(d = hole);
  21. }
  22. }
  23. }
  24. }
  25. }
  26. module base() {
  27. hull() {
  28. for (count = square_corners(width, height, rounding)) {
  29. corner(count, rounding, count.y < 0);
  30. }
  31. }
  32. }
  33. difference() {
  34. base();
  35. holes();
  36. }
  37. }
  38. module center_side() {
  39. hull() {
  40. for (count = square_corners(width, width, rounding)) {
  41. corner(count, rounding, count.y > 0 || count.x < 0);
  42. }
  43. }
  44. }
  45. module rotated(count) {
  46. rotate(count) {
  47. translate([0, height / 2 + width / 2]) {
  48. single_side();
  49. }
  50. }
  51. }
  52. move_x = -width / 2;
  53. move_y = width / 2;
  54. translate([move_x, move_y]) {
  55. render() {
  56. rotated(0);
  57. rotated(90);
  58. center_side();
  59. }
  60. }
  61. }
  62. module connector_object() {
  63. color("#FAAFCB") {
  64. linear_extrude(height = connector_thickness, center = true) {
  65. connector_shape();
  66. }
  67. }
  68. }