flip.scad 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. //Render conductive or non-conductive parts
  2. conductive = false;
  3. //Render the cross section or complete object
  4. crossSection = true;
  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. //Base block where everything else gets cut out
  12. module baseBlock() {
  13. translate([0,0,3.5])
  14. cylinder(r=17,h=51, $fa=1, $fs=0.5, center=true);
  15. }
  16. //Cylinder cut out, outer ring
  17. module outerRingCutOut() {
  18. color("blue")
  19. translate([0,0,-1])
  20. cylinder(r=14,h=30, $fa=1, $fs=0.5, center=true);
  21. }
  22. //The hole through which the water can be filled in later
  23. module fillInHole() {
  24. color("blue")
  25. translate([0,0,23])
  26. cylinder(r=1,h=14, $fa=1, $fs=0.5, center=true);
  27. }
  28. //Parting wall, inner cylinder, cut out
  29. module partingWallInner() {
  30. color("blue")
  31. cylinder(r=6.5,h=30, $fa=1, $fs=0.5, center=true);
  32. }
  33. //Parting wall, outer cylinder, wall thickness
  34. module partingWallOuter() {
  35. cylinder(r=8,h=30, $fa=1, $fs=0.5, center=true);
  36. }
  37. //Combining the two to one module, complete parting wall
  38. module partingWall() {
  39. translate([0,0,-1])
  40. difference() {
  41. partingWallOuter();
  42. partingWallInner();
  43. }
  44. }
  45. //Parting wall, ceiling
  46. module partingWallCeiling() {
  47. color("blue")
  48. translate([0,0,14])
  49. difference() {
  50. sphere(r=8, center=true);
  51. sphere(r=6.5, center=true);
  52. translate([0,0,-5])
  53. cube([20,20,10], center=true);
  54. translate([0,0,7])
  55. rotate([0,0,90])
  56. cylinder(r=3.5,h=4, $fa=1, $fs=0.5, center=true);
  57. }
  58. }
  59. //Cut out sphere, ceiling for the whole object
  60. module ball() {
  61. color("blue")
  62. sphere(r=14, center=true);
  63. }
  64. //cube that cuts away half the ball
  65. module cutCube() {
  66. translate([0,0,-7.5])
  67. cube([30,30,15],center=true);
  68. }
  69. //Ceiling for the whole object
  70. module ceiling() {
  71. translate([0,0,14])
  72. difference() {
  73. ball();
  74. cutCube();
  75. if (fillLater)
  76. fillInHole();
  77. }
  78. }
  79. //Slope to collect the water at one point
  80. module slope() {
  81. difference() {
  82. translate([5,0,-16])
  83. rotate([0,-30,0])
  84. cylinder(r=16.5, h=20, $fa=1, $fs=0.5, center=true);
  85. partingWallInner();
  86. }
  87. }
  88. //Connects the conductive point on the touch screen with the inner conductive part
  89. module condConnectionHorizontal() {
  90. color("red")
  91. translate([-4.5,0,-19])
  92. cube([12,4,2], center=true);
  93. }
  94. //Conductive part on the bottom that connects to the touch screen
  95. module condTouchscreen() {
  96. color("red")
  97. translate([0,0,-21])
  98. cylinder(r=2, h=2, $fa=1, $fs=0.5, center=true);
  99. }
  100. //Conductive part that connects the inner conductive part with the touch screen
  101. module condConnectionVertical() {
  102. color("red")
  103. translate([-9.5,0,-16])
  104. cube([2,4,4], center=true);
  105. }
  106. //Conductive part inside for touchscreen
  107. module condFloor() {
  108. intersection() {
  109. color("red")
  110. translate([-9.5,0,-13])
  111. cube([2,16,2], center=true);
  112. slope();
  113. }
  114. }
  115. //Conducitve part for the finger
  116. module condFinger() {
  117. difference() {
  118. intersection() {
  119. color("red")
  120. translate([-15.5,0,-8])
  121. rotate([0,90,0])
  122. cylinder(r=2, h=4, $fa=1, $fs=0.5, center=true);
  123. baseBlock();
  124. }
  125. outerRingCutOut();
  126. }
  127. }
  128. //All conductive parts in one module
  129. module conductive() {
  130. union() {
  131. condConnectionHorizontal();
  132. condTouchscreen();
  133. condConnectionVertical();
  134. condFloor();
  135. condFinger();
  136. }
  137. }
  138. //The complete object
  139. module completeObject() {
  140. union() {
  141. difference() {
  142. baseBlock();
  143. union() {
  144. outerRingCutOut();
  145. if (fillLater)
  146. fillInHole();
  147. ceiling();
  148. conductive();
  149. }
  150. }
  151. partingWall();
  152. partingWallCeiling();
  153. difference() {
  154. intersection() {
  155. slope();
  156. baseBlock();
  157. }
  158. conductive();
  159. }
  160. }
  161. }
  162. //Render the object depending on the input
  163. if (crossSection) {
  164. difference() {
  165. if (conductive) {
  166. conductive();
  167. }
  168. else {
  169. completeObject();
  170. }
  171. translate([-30,-60,-30])
  172. cube([60,60,60]);
  173. }
  174. }
  175. else {
  176. if (conductive) {
  177. conductive();
  178. }
  179. else {
  180. completeObject();
  181. }
  182. }