Advertisement
Guest User

Untitled

a guest
May 26th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.09 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. linear_extrude (20) 2020tslot(width=40,height=40,cut=[1,2,3,4,5,6,7,8,9,10]);
  14.  
  15.  
  16.  
  17.  
  18.  
  19. module 2020tslot (width=20,height=20,cut=[1,2,3,4]) {
  20.  
  21. //function boolsearch (value,list) = [if (search(value,list) != []) true else false];
  22. boolsearch = function (value,list)
  23. (search(value,list) != []) ? true : false;
  24.  
  25. slotcut = [[10,-4.5], [8.25,-3], [8.25,-5], [6.05,-5], [4,-2.95], [4,-0.2], [3.8,0], [4,0.2], [4,2.95], [6.05,5], [8.25,5], [8.25,3], [10,4.5]];
  26. ecut = [for (i = [0:12]) slotcut[i]];
  27. ncut = [for (i = [0:12]) [(slotcut[i][0]*cos(90))-(slotcut[i][1]*sin(90)),(slotcut[i][0]*sin(90))+(slotcut[i][1]*cos(90))]];
  28. wcut = [for (i = [0:12]) [(slotcut[i][0]*cos(180))-(slotcut[i][1]*sin(180)),(slotcut[i][0]*sin(180))+(slotcut[i][1]*cos(180))]];
  29. scut = [for (i = [0:12]) [(slotcut[i][0]*cos(270))-(slotcut[i][1]*sin(270)),(slotcut[i][0]*sin(270))+(slotcut[i][1]*cos(270))]];
  30. boreangle = ($fn < 20) ? [for (i = [0:19]) [2*cos(i*(360/20)),2*sin(i*(360/20))]] : [for (i = [0:$fn-1]) [2*cos(i*(360/$fn)),2*sin(i*(360/$fn))]];
  31. centercut =
  32. ((width==40)&&(height==40)) ? concat([[3.5,-18.25]], [[3.5,-15.5]], [[6,-13.1]], [[6,-10]], [for (i=[19:-1:0]) [4*cos(i*(360/20/4)+90)+10,4*sin(i*(360/20/4)+90)-10]], [[10,-6]], [[13.1,-6]], [[15.5,-3.5]], [[18.25,-3.5]], [[18.25,3.5]], [[15.5,3.5]], [[13.1,6]], [[10,6]], [for (i=[19:-1:0]) [4*cos(i*(360/20/4)+180)+10,4*sin(i*(360/20/4)+180)+10]], [[6,10]], [[6,13.1]], [[3.5,15.5]], [[3.5,18.25]], [[-3.5,18.25]], [[-3.5,15.5]], [[-6,13.1]], [[-6,10]], [for (i=[19:-1:0]) [4*cos(i*(360/20/4)+270)-10,4*sin(i*(360/20/4)+270)+10]], [[-10,6]], [[-13.1,6]], [[-15.5,3.5]], [[-18.25,3.5]], [[-18.25,-3.5]], [[-15.5,-3.5]], [[-13.1,-6]], [[-10,-6]], [for (i=[19:-1:0]) [4*cos(i*(360/20/4))-10,4*sin(i*(360/20/4))-10]], [[-6,-10]], [[-6,-13.1]], [[-3.5,-15.5]], [[-3.5,-18.25]]) : [[3.5,-8.25], [3.5,-5.5], [6,-3.1], [6,-0.2], [6.2,0], [6,0.2], [6,3.1], [3.5,5.5], [3.5,8.25], [-3.5,8.25], [-3.5,5.5], [-6,3.1], [-6,0.2], [-6.2,0], [-6,-0.2], [-6,-3.1], [-3.5,-5.5], [-3.5,-8.25]];
  33. necorner = [(width/2),(height/2)];
  34. nwcorner = [-(width/2),(height/2)];
  35. swcorner = [-(width/2),-(height/2)];
  36. secorner = [(width/2),-(height/2)];
  37.  
  38. 2020prof = [concat((boolsearch(1,cut)) ? [each[for(i=[0:12])ecut[i],necorner]] : [necorner],(boolsearch(2,cut)) ? [each[for(i=[0:12])ncut[i],nwcorner]] : [nwcorner],(boolsearch(3,cut)) ? [each[for(i=[0:12])wcut[i],swcorner]] : [swcorner],(boolsearch(4,cut)) ? [each[for(i=[0:12])scut[i],secorner]] : [secorner])];
  39. 2040prof = [concat((boolsearch(1,cut)) ? [each[for(i=[0:12])[ecut[i][0]+10,ecut[i][1]],necorner]] : [necorner], (boolsearch(2,cut)) ? [each[for(i=[0:12])[ncut[i][0]+10,ncut[i][1]],[0,10]]]:[[0,10]],(boolsearch(3,cut)) ? [each[for(i=[0:12])[ncut[i][0]-10,ncut[i][1]],nwcorner]] : [nwcorner], (boolsearch(4,cut)) ? [each[for(i=[0:12])[wcut[i][0]-10,wcut[i][1]],swcorner]] : [swcorner], (boolsearch(5,cut)) ? [each[for(i=[0:12])[scut[i][0]-10,scut[i][1]],[0,-10]]] : [[0,-10]], (boolsearch(6,cut)) ? [each[for(i=[0:12])[scut[i][0]+10,scut[i][1]],secorner]] : [secorner])];
  40. 2060prof = [concat((boolsearch(1,cut)) ? [each[for(i=[0:12])[ecut[i][0]+20,ecut[i][1]],necorner]] : [necorner], (boolsearch(2,cut)) ? [each[for(i=[0:12])[ncut[i][0]+20,ncut[i][1]],[20,10]]] : [[20,10]],(boolsearch(3,cut)) ? [each[for(i=[0:12])ncut[i]]] : [[0,10]],(boolsearch(4,cut)) ? [each[for(i=[0:12])[ncut[i][0]-20,ncut[i][1]],nwcorner]] : [nwcorner],(boolsearch(5,cut)) ? [each[for(i=[0:12])[wcut[i][0]-20,wcut[i][1]],swcorner]] : [swcorner],(boolsearch(6,cut)) ? [each[for(i=[0:12])[scut[i][0]-20,scut[i][1]],[-10,-10]]] : [[-10,-10]],(boolsearch(7,cut)) ? [each[for(i=[0:12])scut[i]]] : [[0,-10]],(boolsearch(8,cut)) ? [each[for(i=[0:12])[scut[i][0]+20,scut[i][1]],secorner]] : [secorner])];
  41. 2080prof = [concat((boolsearch(1,cut)) ? [each[for(i=[0:12])[ecut[i][0]+30,ecut[i][1]],necorner]] : [necorner], (boolsearch(2,cut)) ? [each[for(i=[0:12])[ncut[i][0]+30,ncut[i][1]]]] : [[30,10]], (boolsearch(3,cut)) ? [each[for(i=[0:12])[ncut[i][0]+10,ncut[i][1]]]] : [[10,10]], (boolsearch(4,cut)) ? [each[for(i=[0:12])[ncut[i][0]-10,ncut[i][1]]]] : [[-10,10]], (boolsearch(5,cut)) ? [each[for(i=[0:12])[ncut[i][0]-30,ncut[i][1]],nwcorner]] : [nwcorner], (boolsearch(6,cut)) ? [each[for(i=[0:12])[wcut[i][0]-30,wcut[i][1]],swcorner]] : [swcorner], (boolsearch(7,cut)) ? [each[for(i=[0:12])[scut[i][0]-30,scut[i][1]]]] : [[-30,-10]], (boolsearch(8,cut)) ? [each[for(i=[0:12])[scut[i][0]-10,scut[i][1]]]] : [[-10,-10]], (boolsearch(9,cut)) ? [each[for(i=[0:12])[scut[i][0]+10,scut[i][1]]]] : [[10,-10]],(boolsearch(10,cut)) ? [each[for(i=[0:12])[scut[i][0]+30,scut[i][1]],secorner]] : [secorner])];
  42. 4040prof = [concat((boolsearch(1,cut)) ? [each[for(i=[0:12])[ecut[i][0]+10,ecut[i][1]-10],[20,0]]] : [[20,0]], (boolsearch(2,cut)) ? [each[for(i=[0:12])[ecut[i][0]+10,ecut[i][1]+10],necorner]] : [necorner], (boolsearch(3,cut)) ? [each[for(i=[0:12])[ncut[i][0]+10,ncut[i][1]+10],[10,20]]] : [[10,20]], (boolsearch(4,cut)) ? [each[for(i=[0:12])[ncut[i][0]-10,ncut[i][1]+10],nwcorner]] : [nwcorner], (boolsearch(5,cut)) ? [each[for(i=[0:12])[wcut[i][0]-10,wcut[i][1]+10],[-20,0]]] : [[-20,0]], (boolsearch(6,cut)) ? [each[for(i=[0:12])[wcut[i][0]-10,wcut[i][1]-10],swcorner]] : [swcorner], (boolsearch(7,cut)) ? [each[for(i=[0:12])[scut[i][0]-10,scut[i][1]-10],[0,-20]]] : [[0,-20]], (boolsearch(8,cut)) ? [each[for(i=[0:12])[scut[i][0]+10,scut[i][1]-10],secorner]] : [secorner])];
  43.  
  44. polylen = (width == 20) ? len(2020prof[0]) : ((width==40)&&(height==20)) ? len(2040prof[0]) : (width==60) ? len(2060prof[0]) : (width==80) ? len(2080prof[0]) : ((width==40)&&(height==40)) ? len(4040prof[0]) : 0/0;
  45. borepathlen = len(boreangle);
  46. centerlen = len(centercut);
  47.  
  48. borecut = [(width==20) ? [for (i=[0:borepathlen-1]) boreangle[i]] : ((width==40)&&(height==20)) ? concat([for (i=[0:borepathlen-1]) [boreangle[i][0]-10,boreangle[i][1]]],[for (i=[0:borepathlen-1]) [boreangle[i][0]+10,boreangle[i][1]]]) : (width==60) ? concat([for(i=[0:borepathlen-1]) [boreangle[i][0]-20,boreangle[i][1]]],[for(i=[0:borepathlen-1]) boreangle[i]],[for(i=[0:borepathlen-1]) [boreangle[i][0]+20,boreangle[i][1]]]) : (width==80) ? concat([for (i=[0:borepathlen-1]) [boreangle[i][0]-30,boreangle[i][1]]],[for (i=[0:borepathlen-1]) [boreangle[i][0]-10,boreangle[i][1]]],[for (i=[0:borepathlen-1]) [boreangle[i][0]+10,boreangle[i][1]]],[for (i=[0:borepathlen-1]) [boreangle[i][0]+30,boreangle[i][1]]]) : ((width==40)&&(height==40)) ? concat([for (i=[0:borepathlen-1]) [boreangle[i][0]+10,boreangle[i][1]-10]],[for (i=[0:borepathlen-1]) [boreangle[i][0]+10,boreangle[i][1]+10]],[for (i=[0:borepathlen-1]) [boreangle[i][0]-10,boreangle[i][1]+10]],[for (i=[0:borepathlen-1]) [boreangle[i][0]-10,boreangle[i][1]-10]]) : [0/0]];
  49. centercutx = [(width==60) ? concat([for (i=[0:centerlen-1]) [centercut[i][0]-10,centercut[i][1]]],[for (i=[0:centerlen-1]) [centercut[i][0]+10,centercut[i][1]]]) : (width==80) ? concat([for (i=[0:centerlen-1]) [centercut[i][0]-20,centercut[i][1]]],[for (i=[0:centerlen-1]) centercut[i]],[for (i=[0:centerlen-1]) [centercut[i][0]+20,centercut[i][1]]]) : 0/0];
  50.  
  51. outerpath = [for (i = [0:polylen-1]) i];
  52. //borepath = [(width==20) ? [for (i = [0:borepathlen-1]) i+polylen] : ((width==40)&&(height==20)) ? [[for (i = [0:borepathlen-1]) i+polylen],[for (i = [0:borepathlen-1]) i+polylen+borepathlen]] : (width==60) ? [[for (i = [0:borepathlen-1]) i+polylen],[for (i = [0:borepathlen-1]) i+polylen+borepathlen],[for (i = [0:borepathlen-1]) i+polylen+(borepathlen*2)]] : ((width==80)||(width==40)&&(height==40)) ? [[for (i = [0:borepathlen-1]) i+polylen],[for (i = [0:borepathlen-1]) i+polylen+borepathlen],[for (i = [0:borepathlen-1]) i+polylen+(borepathlen*2)],[for (i = [0:borepathlen-1]) i+polylen+(borepathlen*3)]] : 0];
  53.  
  54.  
  55. borepath = [(width==20) ? [for (i = [0:borepathlen-1]) i+polylen] : ((width==40)&&(height==20)) ? [[for (i = [0:borepathlen-1]) i+polylen],[for (i = [0:borepathlen-1]) i+polylen+borepathlen]] : (width==60) ? [[for (i = [0:borepathlen-1]) i+polylen],[for (i = [0:borepathlen-1]) i+polylen+borepathlen],[for (i = [0:borepathlen-1]) i+polylen+(borepathlen*2)]] : ((width==80)||(width==40)&&(height==40)) ? [[for (i = [0:borepathlen-1]) i+polylen],[for (i = [0:borepathlen-1]) i+polylen+borepathlen],[for (i = [0:borepathlen-1]) i+polylen+(borepathlen*2)],[for (i = [0:borepathlen-1]) i+polylen+(borepathlen*3)]] : 0];
  56.  
  57. centerpath = [ ((width==40)&&(height==20)) ? [for (i = [0:centerlen-1]) i+polylen+(borepathlen*2)] : (width==60) ? [[for(i = [0:centerlen-1]) i+polylen+(borepathlen*3)],[for(i = [0:centerlen-1]) i+polylen+(borepathlen*3)+centerlen]] : (width==80) ? [[for (i=[0:centerlen-1]) i+polylen+(borepathlen*4)],[for (i=[0:centerlen-1]) i+polylen+(borepathlen*4)+centerlen],[for (i=[0:centerlen-1]) i+polylen+(borepathlen*4)+(centerlen*2)]] : ((width==40)&&(height==40)) ? [for (i=[0:centerlen-1]) i+polylen+(borepathlen*4)] : [0/0]];
  58.  
  59. echo(centercut)
  60. echo(borepath)
  61.  
  62. if (width==20) {
  63. polygon (
  64. points = [
  65. for (i = [0:polylen-1]) 2020prof[0][i],
  66. for (i = [0:borepathlen-1]) borecut[0][i]
  67. ],
  68. paths = [
  69. outerpath,borepath[0]
  70. ]
  71. );
  72. };
  73.  
  74. if ((width==40)&&(height==20)) {
  75. polygon (
  76. points = [
  77. for (i = [0:polylen-1]) 2040prof[0][i],
  78. for (i = [0:borepathlen*2-1]) borecut[0][i],
  79. for (i = [0:centerlen-1]) centercut[i]
  80. ],
  81. paths = [
  82. outerpath,borepath[0][0],borepath[0][1],centerpath[0]
  83. ]
  84. );
  85. };
  86.  
  87. if ((width==60)&&(height==20)) {
  88. polygon (
  89. points = [
  90. for (i = [0:polylen-1]) 2060prof[0][i],
  91. for (i = [0:borepathlen*3-1]) borecut[0][i],
  92. for (i = [0:centerlen*2-1]) centercutx[0][i]
  93. ],
  94. paths = [
  95. outerpath,borepath[0][0],borepath[0][1],borepath[0][2],centerpath[0][0],centerpath[0][1]
  96. ]
  97. );
  98. };
  99.  
  100. if ((width==80)&&(height==20)) {
  101. polygon (
  102. points = [
  103. for (i = [0:polylen-1]) 2080prof[0][i],
  104. for (i = [0:borepathlen*4-1]) borecut[0][i],
  105. for (i = [0:centerlen*3-1]) centercutx[0][i]
  106. ],
  107. paths = [
  108. outerpath,borepath[0][0],borepath[0][1],borepath[0][2],borepath[0][3],centerpath[0][0],centerpath[0][1],centerpath[0][2]
  109. ]
  110. );
  111. };
  112.  
  113. if ((width==40)&&(height==40)) {
  114. polygon (
  115. points = [
  116. for (i=[0:polylen-1]) 4040prof[0][i],
  117. for (i=[0:borepathlen*4-1]) borecut[0][i],
  118. for (i=[0:centerlen-1]) centercut[i]
  119. ],
  120. paths = [
  121. //outerpath,borepath[0][0],borepath[0][1],borepath[0][2],borepath[0][3],centerpath[0]
  122. outerpath,([for (i=[3:-1:0]) borepath[0][i]]),centerpath[0]
  123. ]
  124. );
  125. };
  126.  
  127. };
  128.  
  129.  
  130.  
  131. /*module 2020tslot () {
  132.  
  133. //translate ([2.95,4]) rotate (-45) #square ([1.5,0.5]);
  134.  
  135. eastcut = [[10,-4.5], [8.25,-3], [8.25,-5], [6.05,-5], [4,-2.95], [4,-0.2], [3.8,0], [4,0.2], [4,2.95], [6.05,5], [8.25,5], [8.25,3], [10,4.5]];
  136. northcut = [[4.5,10], [3,8.25], [5,8.25], [5,6.05], [2.95,4], [0.2,4], [0,3.8], [-0.2,4], [-2.95,4], [-5,6.05], [-5,8.25], [-3,8.25], [-4.5,10]];
  137. westcut = [[-10,4.5], [-8.25,3], [-8.25,5], [-6.05,5], [-4,2.95], [-4,0.2], [-3.8,0], [-4,-0.2], [-4,-2.95], [-6.05,-5], [-8.25,-5], [-8.25,-3], [-10,-4.5]];
  138. southcut = [[-4.5,-10], [-3,-8.25], [-5,-8.25], [-5,-6.05], [-2.95,-4], [-0.2,-4], [0,-3.8], [0.2,-4], [2.95,-4], [5,-6.05], [5,-8.25], [3,-8.25], [4.5,-10]];
  139. boreangle = ($fn < 20) ? [for (i = [0:19]) [2*cos(i*(360/20)),2*sin(i*(360/20))]] : [for (i = [0:$fn-1]) [2*cos(i*(360/$fn)),2*sin(i*(360/$fn))]];
  140. outerpath = [for (i = [0:55]) i];
  141. borepath = ($fn < 20) ? [for (i = [0:19]) i+56] : [for (i = [0:$fn-1]) i+56];
  142. borepathlen = len(boreangle);
  143.  
  144. polygon (
  145. points = [
  146. for (i = [0:1:12]) eastcut[i],
  147. [10,10],
  148. for (i = [0:1:12]) northcut[i],
  149. [-10,10],
  150. for (i = [0:1:12]) westcut[i],
  151. [-10,-10],
  152. for (i = [0:1:12]) southcut[i],
  153. [10,-10],
  154. for (i = [0:borepathlen-1]) boreangle[i]
  155. ],
  156. paths = [outerpath,borepath]
  157. );
  158.  
  159. };
  160.  
  161. module 2040tslot () {
  162.  
  163. //translate ([6,3.1]) rotate (45) #square ([1.5,0.5]);
  164.  
  165. eastcut = [[20,-4.5], [18.25,-3], [18.25,-5], [16.05,-5], [14,-2.95], [14,-0.2], [13.8,0], [14,0.2], [14,2.95], [16.05,5], [18.25,5], [18.25,3], [20,4.5]];
  166. northeastcut = [[14.5,10], [13,8.25], [15,8.25], [15,6.05], [12.95,4], [10.2,4], [10,3.8], [9.8,4], [7.25,4], [5,6.05], [5,8.25], [7,8.25], [5.5,10]];
  167. northwestcut = [[-5.5,10], [-7,8.25], [-5,8.25], [-5,6.05], [-7.25,4], [-9.8,4], [-10,3.8], [-10.2,4], [-12.95,4], [-15,6.05], [-15,8.25], [-13,8.25], [-14.5,10]];
  168. westcut = [[-20,4.5], [-18.25,3], [-18.25,5], [-16.05,5], [-14,2.95], [-14,0.2], [-13.8,0], [-14,-0.2], [-14,-2.95], [-16.05,-5], [-18.25,-5], [-18.25,-3], [-20,-4.5]];
  169. southwestcut = [[-5.5,-10], [-7,-8.25], [-5,-8.25], [-5,-6.05], [-7.25,-4], [-9.8,-4], [-10,-3.8], [-10.2,-4], [-12.95,-4], [-15,-6.05], [-15,-8.25], [-13,-8.25], [-14.5,-10]];
  170. southeastcut = [[14.5,-10], [13,-8.25], [15,-8.25], [15,-6.05], [12.95,-4], [10.2,-4], [10,-3.8], [9.8,-4], [7.25,-4], [5,-6.05], [5,-8.25], [7,-8.25], [5.5,-10]];
  171. eastboreangle = ($fn < 20) ? [for (i = [0:19]) [10+(2*cos(i*(360/20))),2*sin(i*(360/20))]] : [for (i = [0:$fn-1]) [10+(2*cos(i*(360/$fn))),2*sin(i*(360/$fn))]];
  172. westboreangle = ($fn < 20) ? [for (i = [0:19]) [-10+(2*cos(i*(360/20))),2*sin(i*(360/20))]] : [for (i = [0:$fn-1]) [-10+(2*cos(i*(360/$fn))),2*sin(i*(360/$fn))]];
  173. centercut = [[3.5,-8.25], [3.5,-5.5], [6,-3.1], [6,-0.2], [6.2,0], [6,0.2], [6,3.1], [3.5,5.5], [3.5,8.25], [-3.5,8.25], [-3.5,5.5], [-6,3.1], [-6,0.2], [-6.2,0], [-6,-0.2], [-6,-3.1], [-3.5,-5.5], [-3.5,-8.25]];
  174. outerpath = [for (i = [0:81]) i];
  175. westborepath = ($fn < 20) ? [for (i = [0:19]) i+82] : [for (i = [0:$fn-1]) i+82];
  176. borepathlen = len(westboreangle);
  177. eastborepath = ($fn < 20) ? [for (i = [0:19]) i+82+borepathlen] : [for (i = [0:$fn-1]) i+82+borepathlen];
  178. centerpath = [for (i = [0:17]) i+82+(borepathlen*2)];
  179.  
  180. polygon (
  181. points = [
  182. for (i = [0:1:12]) eastcut[i],
  183. [20,10],
  184. for (i = [0:1:12]) northeastcut[i],
  185. for (i = [0:1:12]) northwestcut[i],
  186. [-20,10],
  187. for (i = [0:1:12]) westcut[i],
  188. [-20,-10],
  189. for (i = [0:1:12]) southwestcut[i],
  190. for (i = [0:1:12]) southeastcut[i],
  191. [20,-10],
  192. for (i = [0:borepathlen-1]) westboreangle[i],
  193. for (i = [0:borepathlen-1]) eastboreangle[i],
  194. for (i = [0:1:17]) centercut[i]
  195. ],
  196. paths = [outerpath,westborepath,eastborepath,centerpath]
  197. );
  198.  
  199. };*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement