connector.scad 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. include <../config/connector.scad>
  2. include <../config/plate.scad>
  3. include <ATX.scad>
  4. function connector_holes_pattern() = [
  5. [connector_mount_width / 2, connector_mount_height / 2],
  6. [connector_mount_width / 2, -connector_mount_height / 2],
  7. [0, connector_mount_height / 2],
  8. [0, -connector_mount_height / 2],
  9. [-connector_mount_width / 2, connector_mount_height / 2],
  10. [-connector_mount_width / 2, -connector_mount_height / 2],
  11. ];
  12. module connector_object() {
  13. depth = connector_depth;
  14. height = connector_height;
  15. rounding = connector_rounding;
  16. thickness = connector_thickness;
  17. rods = connector_rods;
  18. hole = connector_hole;
  19. screwdriver_hole = connector_screwdriver_hole;
  20. module cross_shape(scaled = false, cut = true) {
  21. module corner(x = 0, y = 0) {
  22. translate([x, y]) {
  23. circle(r = rounding);
  24. }
  25. }
  26. move_x = depth / 2 - rounding;
  27. move_y = height / 2 - rounding;
  28. if (!scaled) {
  29. difference() {
  30. hull() {
  31. corner(move_x, move_y);
  32. corner(-move_x, move_y);
  33. corner(-move_x, -move_y);
  34. }
  35. if (cut) {
  36. cross_shape(scaled = true);
  37. }
  38. }
  39. } else {
  40. scaled_x = (move_x - rods) / move_x;
  41. scaled_y = (move_y - rods) / move_y;
  42. scale([scaled_x, scaled_y]) {
  43. x_change = move_x - move_x * scaled_x;
  44. y_change = move_y - move_y * scaled_y;
  45. translate([-x_change / 2, y_change / 2])
  46. cross_shape(scaled = false, cut = false);
  47. }
  48. }
  49. }
  50. module base_object() {
  51. rotate([90, 0, 0]) {
  52. linear_extrude(height = thickness, center = true) {
  53. cross_shape();
  54. }
  55. }
  56. }
  57. module top_holes(size = height) {
  58. for (count = connector_holes_pattern()) {
  59. translate([count.x, count.y, 0]) {
  60. cylinder(h = size, r = hole / 2, center = true);
  61. translate([0, 0, -rods]) {
  62. cylinder(
  63. h = size,
  64. r = screwdriver_hole / 2,
  65. center = true
  66. );
  67. }
  68. }
  69. }
  70. }
  71. module side_holes() {
  72. rotate([0, 90, 180]) {
  73. top_holes(size = depth);
  74. }
  75. }
  76. module final_object() {
  77. difference() {
  78. base_object();
  79. top_holes();
  80. side_holes();
  81. }
  82. }
  83. color("#222222") {
  84. render() {
  85. final_object();
  86. }
  87. }
  88. }