connector.scad 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. include <../config/connector.scad>
  2. module connector_shape() {
  3. rounding = connector_depth / 2;
  4. move = connector_width - rounding * 2;
  5. width = connector_width;
  6. module base_shape(split = false) {
  7. if (!split) {
  8. hull() {
  9. circle(r = rounding);
  10. translate([move, 0]) {
  11. circle(r = rounding);
  12. }
  13. }
  14. } else {
  15. translate([-move, 0]) {
  16. base_shape(split = false);
  17. }
  18. }
  19. }
  20. module holes(split = false) {
  21. if (!split) {
  22. space_y = rounding * 2 / (connector_holes_in_y + 1);
  23. space_x = move / (connector_holes_in_x - 1);
  24. for (count_y = [-rounding : space_y : rounding]) {
  25. if (count_y != rounding && count_y != -rounding) {
  26. for (count_x = [0 : space_x : move]) {
  27. translate([count_x, count_y]) {
  28. circle(r = connector_hole / 2);
  29. }
  30. }
  31. }
  32. }
  33. } else {
  34. translate([-move, 0]) {
  35. holes(split = false);
  36. }
  37. }
  38. }
  39. module final_shape(split = false) {
  40. difference() {
  41. base_shape(split);
  42. holes(split);
  43. }
  44. }
  45. module final_solid() {
  46. render() {
  47. hull() {
  48. base_shape(split = false);
  49. if (connector_dual) {
  50. base_shape(split = true);
  51. }
  52. rotate(180 - connector_angle) {
  53. final_shape(split = true);
  54. }
  55. }
  56. }
  57. }
  58. module final_holes() {
  59. holes(split = false);
  60. if (connector_dual) {
  61. holes(split = true);
  62. }
  63. rotate(180 - connector_angle) {
  64. holes(split = true);
  65. }
  66. }
  67. render() {
  68. difference() {
  69. final_solid();
  70. final_holes();
  71. }
  72. }
  73. }
  74. module connector_object() {
  75. color("#FAAFCB") {
  76. linear_extrude(height = connector_thickness, center = true) {
  77. connector_shape();
  78. }
  79. }
  80. }