connector.scad 1.7 KB

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