weight.scad 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //Render conductive or non-conductive parts
  2. conductive = false;
  3. //Render the cross section or complete object
  4. crossSection = false;
  5. //Add a hole to fill the object after finishing printing
  6. fillLater = true;
  7. //Diameter of the conductive part that will be on the touch screen
  8. sizeScreen=4.0;
  9. //Diameter of the conductive part that will be connected to the finger
  10. sizeFinger=4.0;
  11. //Number of supports between the plates
  12. numberSupports=2;
  13. //Calculate for the for-loop
  14. a=numberSupports/2 - 1;
  15. //First plate
  16. module plateOne() {
  17. cube([61,20,4], center=true);
  18. }
  19. //Second plate
  20. module plateTwo() {
  21. translate([0,0,10])
  22. cube([61,20,4], center=true);
  23. }
  24. //Supports between the plates, number dependend on input
  25. module supports() {
  26. color("red")
  27. for (i = [0:1:a]) {
  28. translate([-26+i*8,0,5])
  29. rotate([0,45,0])
  30. cube([0.5,20,12], center=true);
  31. }
  32. color("red")
  33. for (i = [0:1:a]) {
  34. translate([26-i*8,0,5])
  35. rotate([0,45,0])
  36. cube([0.5,20,12], center=true);
  37. }
  38. }
  39. //Larger bottom area for better printing
  40. module printSupportOne() {
  41. translate([0,-9.75,-3])
  42. rotate([90,0,0])
  43. cube([61,10,0.5], center=true);
  44. }
  45. module printSupportTwo() {
  46. translate([0,-9.75,13])
  47. rotate([90,0,0])
  48. cube([61,10,0.5], center=true);
  49. }
  50. //Conductive bars between the plates
  51. module condBar1() {
  52. color("red")
  53. translate([1,0,2.25])
  54. cube([4,20,2],center=true);
  55. }
  56. module condBar2() {
  57. color("red")
  58. translate([-1,0,7.75])
  59. cube([4,20,2],center=true);
  60. }
  61. //Conductive pins on the outside, connected to the finger or touchscreen
  62. module condPin1() {
  63. color("red")
  64. translate([1,0,-0.05])
  65. cylinder(r=sizeFinger/2,h=4.1, $fa=1, $fs=0.5, center=true);
  66. }
  67. module condPin2() {
  68. color("red")
  69. translate([-1,0,10.05])
  70. cylinder(r=sizeScreen/2,h=4.1, $fa=1, $fs=0.5, center=true);
  71. }
  72. //All conductive parts in one module
  73. module conductive() {
  74. union() {
  75. condBar1();
  76. condBar2();
  77. condPin1();
  78. condPin2();
  79. supports();
  80. }
  81. }
  82. //All non-conducitve parts in one module
  83. module completeObject() {
  84. rotate([90,0,0])
  85. difference() {
  86. union() {
  87. plateOne();
  88. plateTwo();
  89. printSupportOne();
  90. printSupportTwo();
  91. }
  92. conductive();
  93. }
  94. }
  95. //Render dependend on inputs
  96. if (crossSection) {
  97. difference() {
  98. if(conductive) {
  99. rotate([90,0,0])
  100. conductive();
  101. }
  102. else {
  103. completeObject();
  104. }
  105. translate([-40,-30,-60])
  106. cube([80,60,60]);
  107. }
  108. }
  109. else {
  110. if(conductive) {
  111. rotate([90,0,0])
  112. conductive();
  113. }
  114. else {
  115. completeObject();
  116. }
  117. }