connector.scad 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. rotate(180 - connector_angle) {
  61. holes(split = true);
  62. }
  63. }
  64. render() {
  65. difference() {
  66. final_solid();
  67. final_holes();
  68. }
  69. }
  70. }
  71. module connector_object() {
  72. color("#FAAFCB") {
  73. linear_extrude(height = connector_thickness, center = true) {
  74. connector_shape();
  75. }
  76. }
  77. }