Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- linear_extrude (20) 2020tslot(width=40,height=40,cut=[1,2,3,4,5,6,7,8,9,10]);
- module 2020tslot (width=20,height=20,cut=[1,2,3,4]) {
- //function boolsearch (value,list) = [if (search(value,list) != []) true else false];
- boolsearch = function (value,list)
- (search(value,list) != []) ? true : false;
- 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]];
- ecut = [for (i = [0:12]) slotcut[i]];
- 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))]];
- 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))]];
- 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))]];
- 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))]];
- centercut =
- ((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]];
- necorner = [(width/2),(height/2)];
- nwcorner = [-(width/2),(height/2)];
- swcorner = [-(width/2),-(height/2)];
- secorner = [(width/2),-(height/2)];
- 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])];
- 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])];
- 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])];
- 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])];
- 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])];
- 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;
- borepathlen = len(boreangle);
- centerlen = len(centercut);
- 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]];
- 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];
- outerpath = [for (i = [0:polylen-1]) i];
- //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];
- 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];
- 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]];
- echo(centercut)
- echo(borepath)
- if (width==20) {
- polygon (
- points = [
- for (i = [0:polylen-1]) 2020prof[0][i],
- for (i = [0:borepathlen-1]) borecut[0][i]
- ],
- paths = [
- outerpath,borepath[0]
- ]
- );
- };
- if ((width==40)&&(height==20)) {
- polygon (
- points = [
- for (i = [0:polylen-1]) 2040prof[0][i],
- for (i = [0:borepathlen*2-1]) borecut[0][i],
- for (i = [0:centerlen-1]) centercut[i]
- ],
- paths = [
- outerpath,borepath[0][0],borepath[0][1],centerpath[0]
- ]
- );
- };
- if ((width==60)&&(height==20)) {
- polygon (
- points = [
- for (i = [0:polylen-1]) 2060prof[0][i],
- for (i = [0:borepathlen*3-1]) borecut[0][i],
- for (i = [0:centerlen*2-1]) centercutx[0][i]
- ],
- paths = [
- outerpath,borepath[0][0],borepath[0][1],borepath[0][2],centerpath[0][0],centerpath[0][1]
- ]
- );
- };
- if ((width==80)&&(height==20)) {
- polygon (
- points = [
- for (i = [0:polylen-1]) 2080prof[0][i],
- for (i = [0:borepathlen*4-1]) borecut[0][i],
- for (i = [0:centerlen*3-1]) centercutx[0][i]
- ],
- paths = [
- outerpath,borepath[0][0],borepath[0][1],borepath[0][2],borepath[0][3],centerpath[0][0],centerpath[0][1],centerpath[0][2]
- ]
- );
- };
- if ((width==40)&&(height==40)) {
- polygon (
- points = [
- for (i=[0:polylen-1]) 4040prof[0][i],
- for (i=[0:borepathlen*4-1]) borecut[0][i],
- for (i=[0:centerlen-1]) centercut[i]
- ],
- paths = [
- //outerpath,borepath[0][0],borepath[0][1],borepath[0][2],borepath[0][3],centerpath[0]
- outerpath,([for (i=[3:-1:0]) borepath[0][i]]),centerpath[0]
- ]
- );
- };
- };
- /*module 2020tslot () {
- //translate ([2.95,4]) rotate (-45) #square ([1.5,0.5]);
- 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]];
- 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]];
- 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]];
- 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]];
- 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))]];
- outerpath = [for (i = [0:55]) i];
- borepath = ($fn < 20) ? [for (i = [0:19]) i+56] : [for (i = [0:$fn-1]) i+56];
- borepathlen = len(boreangle);
- polygon (
- points = [
- for (i = [0:1:12]) eastcut[i],
- [10,10],
- for (i = [0:1:12]) northcut[i],
- [-10,10],
- for (i = [0:1:12]) westcut[i],
- [-10,-10],
- for (i = [0:1:12]) southcut[i],
- [10,-10],
- for (i = [0:borepathlen-1]) boreangle[i]
- ],
- paths = [outerpath,borepath]
- );
- };
- module 2040tslot () {
- //translate ([6,3.1]) rotate (45) #square ([1.5,0.5]);
- 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]];
- 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]];
- 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]];
- 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]];
- 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]];
- 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]];
- 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))]];
- 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))]];
- 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]];
- outerpath = [for (i = [0:81]) i];
- westborepath = ($fn < 20) ? [for (i = [0:19]) i+82] : [for (i = [0:$fn-1]) i+82];
- borepathlen = len(westboreangle);
- eastborepath = ($fn < 20) ? [for (i = [0:19]) i+82+borepathlen] : [for (i = [0:$fn-1]) i+82+borepathlen];
- centerpath = [for (i = [0:17]) i+82+(borepathlen*2)];
- polygon (
- points = [
- for (i = [0:1:12]) eastcut[i],
- [20,10],
- for (i = [0:1:12]) northeastcut[i],
- for (i = [0:1:12]) northwestcut[i],
- [-20,10],
- for (i = [0:1:12]) westcut[i],
- [-20,-10],
- for (i = [0:1:12]) southwestcut[i],
- for (i = [0:1:12]) southeastcut[i],
- [20,-10],
- for (i = [0:borepathlen-1]) westboreangle[i],
- for (i = [0:borepathlen-1]) eastboreangle[i],
- for (i = [0:1:17]) centercut[i]
- ],
- paths = [outerpath,westborepath,eastborepath,centerpath]
- );
- };*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement