-
Notifications
You must be signed in to change notification settings - Fork 4
/
gcodepreviewtemplate.scad
156 lines (130 loc) · 5.37 KB
/
gcodepreviewtemplate.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//!OpenSCAD
use <gcodepreview.py>;
use <pygcodepreview.scad>;
include <gcodepreview.scad>;
$fa = 2;
$fs = 0.125;
/* [Stock] */
stockXwidth = 219;
/* [Stock] */
stockYheight = 150;
/* [Stock] */
stockZthickness = 8.35;
/* [Stock] */
zeroheight = "Top"; // [Top, Bottom]
/* [Stock] */
stockzero = "Center"; // [Lower-Left, Center-Left, Top-Left, Center]
/* [Stock] */
retractheight = 9;
/* [Export] */
Base_filename = "export";
/* [Export] */
generatedxf = true;
/* [Export] */
generategcode = true;
///* [Export] */
//generatesvg = false;
/* [CAM] */
toolradius = 1.5875;
/* [CAM] */
large_square_tool_num = 0; // [0:0,112:112,102:102,201:201]
/* [CAM] */
small_square_tool_num = 102; // [0:0,122:122,112:112,102:102]
/* [CAM] */
large_ball_tool_num = 0; // [0:0,111:111,101:101,202:202]
/* [CAM] */
small_ball_tool_num = 0; // [0:0,121:121,111:111,101:101]
/* [CAM] */
large_V_tool_num = 0; // [0:0,301:301,690:690]
/* [CAM] */
small_V_tool_num = 0; // [0:0,390:390,301:301]
/* [CAM] */
DT_tool_num = 0; // [0:0,814:814]
/* [CAM] */
KH_tool_num = 0; // [0:0,374:374,375:375,376:376,378]
/* [CAM] */
Roundover_tool_num = 0; // [56125:56125, 56142:56142,312:312, 1570:1570]
/* [CAM] */
MISC_tool_num = 0; //
/* [Feeds and Speeds] */
plunge = 100;
/* [Feeds and Speeds] */
feed = 400;
/* [Feeds and Speeds] */
speed = 16000;
/* [Feeds and Speeds] */
small_square_ratio = 0.75; // [0.25:2]
/* [Feeds and Speeds] */
large_ball_ratio = 1.0; // [0.25:2]
/* [Feeds and Speeds] */
small_ball_ratio = 0.75; // [0.25:2]
/* [Feeds and Speeds] */
large_V_ratio = 0.875; // [0.25:2]
/* [Feeds and Speeds] */
small_V_ratio = 0.625; // [0.25:2]
/* [Feeds and Speeds] */
DT_ratio = 0.75; // [0.25:2]
/* [Feeds and Speeds] */
KH_ratio = 0.75; // [0.25:2]
/* [Feeds and Speeds] */
RO_ratio = 0.5; // [0.25:2]
/* [Feeds and Speeds] */
MISC_ratio = 0.5; // [0.25:2]
filename_gcode = str(Base_filename, ".nc");
filename_dxf = str(Base_filename);
opengcodefile(filename_gcode);
opendxffile(filename_dxf);
difference() {
setupstock(stockXwidth, stockYheight, stockZthickness, zeroheight, stockzero);
movetosafez();
toolchange(small_square_tool_num,speed * small_square_ratio);
begintoolpath(0,0,0.25);
cutoneaxis_setfeed("Z",0,plunge*small_square_ratio);
cutwithfeed(stockXwidth/2,stockYheight/2,-stockZthickness,feed);
dxfpolyline(getxpos(),getypos(),stockXwidth/2,stockYheight/2, small_square_tool_num);
endtoolpath();
rapid(-(stockXwidth/4-stockYheight/16),stockYheight/4,0);
cutoneaxis_setfeed("Z",-stockZthickness,plunge*small_square_ratio);
cutarcNECCdxf(-stockXwidth/4, stockYheight/4+stockYheight/16, -stockZthickness, -stockXwidth/4, stockYheight/4, stockYheight/16, small_square_tool_num);
cutarcNWCCdxf(-(stockXwidth/4+stockYheight/16), stockYheight/4, -stockZthickness, -stockXwidth/4, stockYheight/4, stockYheight/16, small_square_tool_num);
cutarcSWCCdxf(-stockXwidth/4, stockYheight/4-stockYheight/16, -stockZthickness, -stockXwidth/4, stockYheight/4, stockYheight/16, small_square_tool_num);
cutarcSECCdxf(-(stockXwidth/4-stockYheight/16), stockYheight/4, -stockZthickness, -stockXwidth/4, stockYheight/4, stockYheight/16, small_square_tool_num);
rapid(getxpos(),getypos(),stockZthickness);
toolchange(KH_tool_num,speed * KH_ratio);
rapid(-stockXwidth/8,-stockYheight/4,0);
cutkeyhole_toolpath((stockZthickness), (stockZthickness), "N", stockYheight/8, KH_tool_num);
rapid(getxpos(),getypos(),stockZthickness);
rapid(-stockXwidth/4,-stockYheight/4,0);
cutkeyhole_toolpath((stockZthickness), (stockZthickness), "S", stockYheight/8, KH_tool_num);
rapid(getxpos(),getypos(),stockZthickness);
rapid(-stockXwidth/4,-stockYheight/8,0);
cutkeyhole_toolpath((stockZthickness), (stockZthickness), "E", stockYheight/8, KH_tool_num);
rapid(getxpos(),getypos(),stockZthickness);
rapid(-stockXwidth/8,-stockYheight/8*3,0);
cutkeyhole_toolpath((stockZthickness), (stockZthickness), "W", stockYheight/8, KH_tool_num);
rapid(getxpos(),getypos(),stockZthickness);
toolchange(DT_tool_num,speed * DT_ratio);
rapid(0,-(stockYheight/2+tool_diameter(DT_tool_num,0)),0);
cutoneaxis_setfeed("Z",-stockZthickness,plunge*DT_ratio);
cutwithfeed(0,-(stockYheight/4),-stockZthickness,feed*DT_ratio);
rapid(0,-(stockYheight/2+tool_diameter(DT_tool_num,0)),-stockZthickness);
rapid(getxpos(),getypos(),stockZthickness);
toolchange(Roundover_tool_num, speed * RO_ratio);
rapid(-(stockXwidth/2),-(stockYheight/2),0);
cutoneaxis_setfeed("Z",-4.509,plunge*RO_ratio);
cutroundovertool(-(stockXwidth/2++0.507/2), -(stockYheight/2+0.507/2), -4.509, stockXwidth/2+0.507/2, -(stockYheight/2+0.507/2), -4.509, 0.507/2, 4.509);
cutroundover(stockXwidth/2+0.507/2, -(stockYheight/2+0.507/2), -4.509, stockXwidth/2+0.507/2, stockYheight/2+0.507/2, -4.509, 1570);
cutroundover(stockXwidth/2+0.507/2, stockYheight/2+0.507/2, -4.509, -(stockXwidth/2+0.507/2), stockYheight/2+0.507/2, -4.509, 1570);
cutroundover(-(stockXwidth/2+0.507/2), stockYheight/2+0.507/2, -4.509, -(stockXwidth/2+0.507/2), -(stockYheight/2+0.507/2), -4.509, 1570);
//for (i = [0 : abs(1) : 80]) {
// cutwithfeed(stockXwidth/4,-stockYheight/4,-stockZthickness/4,feed);
// cutwithfeed(stockXwidth/8+(stockXwidth/256*i),-stockYheight/2,-stockZthickness*3/4,feed);
// }
hull(){
cutwithfeed(stockXwidth/4,-stockYheight/4,-stockZthickness/4,feed);
cutwithfeed(stockXwidth/8,-stockYheight/2,-stockZthickness*3/4,feed);
cutwithfeed(stockXwidth/8+(stockXwidth*0.3125),-stockYheight/2,-stockZthickness*3/4,feed);
}
}
closegcodefile();
closedxffile();