-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathestlcam.cps
247 lines (192 loc) · 7.15 KB
/
estlcam.cps
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/*
estlCAM Post-Processor for Fusion 360
Using Exiting Post Processors as inspiration
For documentation, see GitHub Wiki : https://github.com/Strooom/GRBL-Post-Processor/wiki
Please notice ESTLCAM does not support other than XY circular movements. (no G18/19)
For that please make sure, that on a milling operation in Fusion 360
on the tab "Anfahrt-Wegfahrbewegungen" / "Vertikaler Einfahrradius" is set to 0 mm
*/
description = "estlCAM Post-Processor for Fusion 360";
vendor = "Franke";
vendorUrl = "";
model = "";
legal = "Copyright (C) 2012-2016 by Autodesk, Inc.";
certificationLevel = 2;
extension = "nc";
setCodePage("ascii");
capabilities = CAPABILITY_MILLING
tolerance = spatial(0.01, MM);
minimumChordLength = spatial(0.01, MM);
minimumCircularRadius = spatial(0.01, MM);
maximumCircularRadius = spatial(1000, MM);
minimumCircularSweep = toRad(0.01);
maximumCircularSweep = toRad(180);
allowHelicalMoves = true;
allowedCircularPlanes = undefined;
var ESTLCAMunits = MM;
// creation of all kinds of G-code formats - controls the amount of decimals used in the generated G-Code
var gFormat = createFormat({prefix:"G", decimals:0});
var mFormat = createFormat({prefix:"M", decimals:0});
var xyzFormat = createFormat({decimals:(unit == MM ? 3 : 4)});
var arcFormat = createFormat({decimals:(unit == MM ? 4 : 5)}); // uses extra digit in arcs
var feedFormat = createFormat({decimals:0});
var rpmFormat = createFormat({decimals:0});
var xOutput = createVariable({prefix:"X"}, xyzFormat);
var yOutput = createVariable({prefix:"Y"}, xyzFormat);
var zOutput = createVariable({prefix:"Z"}, xyzFormat);
var feedOutput = createVariable({prefix:"F"}, feedFormat);
var sOutput = createVariable({prefix:"S", force:true}, rpmFormat);
// for arcs, use extra digit
var xaOutput = createVariable({prefix:"X"}, arcFormat);
var yaOutput = createVariable({prefix:"Y"}, arcFormat);
var zaOutput = createVariable({prefix:"Z"}, arcFormat);
var iOutput = createVariable({prefix:"I"}, arcFormat);
var jOutput = createVariable({prefix:"J"}, arcFormat);
var kOutput = createVariable({prefix:"K"}, arcFormat);
function writeBlock() {
writeWords(arguments);
}
function writeComment(text) {
// Remove special characters which could confuse GRBL : $, !, ~, ?, (, )
// In order to make it simple, I replace everything which is not A-Z, 0-9, space, : , .
// Finally put everything between () as this is the way GRBL & UGCS expect comments
writeln("(" + String(text).replace(/[^a-zA-Z\d :=,.]+/g, " ") + ")");
}
function onOpen() {
// Number of checks capturing fatal errors
// 1. is CAD file in same units as our GRBL configuration ?
if (unit != ESTLCAMunits) {
if (ESTLCAMunits == MM) {
alert("Error", "ESTLCAM configured to mm - CAD file sends Inches! - Change units in CAD/CAM software to mm");
error("Fatal Error : units mismatch between CADfile and ESTLCAM setting");
} else {
alert("Error", "ESTLCAM configured to inches - CAD file sends mm! - Change units in CAD/CAM software to inches");
error("Fatal Error : units mismatch between CADfile and ESTLCAM setting");
}
}
// 2. is RadiusCompensation not set incorrectly ?
onRadiusCompensation();
var productName = getProduct();
writeComment("Made in : " + productName);
if (programName) {
writeComment("Program Name : " + programName);
}
if (programComment) {
writeComment("Program Comments : " + programComment);
}
var numberOfSections = getNumberOfSections();
writeComment(numberOfSections + " Operation" + ((numberOfSections == 1)?"":"s") + " :");
}
function onComment(message) {
writeComment(message);
}
function forceXYZ() {
xOutput.reset();
yOutput.reset();
zOutput.reset();
}
function forceAny() {
forceXYZ();
feedOutput.reset();
}
function onSection() {
var nmbrOfSections = getNumberOfSections();
var sectionId = getCurrentSectionId();
var section = getSection(sectionId);
// Insert a small comment section to identify the related G-Code in a large multi-operations file
var comment = "Operation " + (sectionId + 1) + " of " + nmbrOfSections;
if (hasParameter("operation-comment")) {
comment = comment + " : " + getParameter("operation-comment");
}
writeComment(comment);
writeln("");
var tool = section.getTool();
if(!isFirstSection()) {
var previousTool = getSection(sectionId - 1).getTool();
if (tool.getDescription() != previousTool.getDescription()) {
writeBlock(mFormat.format(6), "(" + tool.getDescription() + ")");
}
}
writeBlock(mFormat.format(3), sOutput.format(tool.spindleRPM));
// If the machine has coolant, write M8 or M9
if (properties.hasCoolant) {
if (tool.coolant) {
writeBlock(mFormat.format(8));
} else {
writeBlock(mFormat.format(9));
}
}
forceXYZ();
var remaining = currentSection.workPlane;
if (!isSameDirection(remaining.forward, new Vector(0, 0, 1))) {
alert("Error", "Tool-Rotation detected - only supports 3 Axis");
error("Fatal Error in Operation " + (sectionId + 1) + ": Tool-Rotation detected but only supports 3 Axis");
}
setRotation(remaining);
forceAny();
// Rapid move to initial position, first XY, then Z
var initialPosition = getFramePosition(currentSection.getInitialPosition());
writeBlock("G00", xOutput.format(initialPosition.x), yOutput.format(initialPosition.y));
writeBlock("G00", zOutput.format(initialPosition.z));
}
function onSpindleSpeed(spindleSpeed) {
writeBlock(sOutput.format(spindleSpeed));
}
function onRadiusCompensation() {
var radComp = getRadiusCompensation();
var sectionId = getCurrentSectionId();
if (radComp != RADIUS_COMPENSATION_OFF) {
alert("Error", "RadiusCompensation is not supported in ESTLCAM - Change RadiusCompensation in CAD/CAM software to Off/Center/Computer");
error("Fatal Error in Operation " + (sectionId + 1) + ": RadiusCompensation is found in CAD file but is not supported in ESTLCAM");
return;
}
}
function onRapid(_x, _y, _z) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
writeBlock("G00", x, y, z);
feedOutput.reset();
}
function onLinear(_x, _y, _z, feed) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
var f = feedOutput.format(feed);
if (x || y || z) {
writeBlock("G01", x, y, z, f);
} else if (f) {
if (getNextRecord().isMotion()) {
feedOutput.reset();
} else {
writeBlock("G01", f);
}
}
}
function onRapid5D(_x, _y, _z, _a, _b, _c) {
alert("Error", "Tool-Rotation detected - ESTLCAM only supports 3 Axis");
error("Tool-Rotation detected but ESTLCAM only supports 3 Axis");
}
function onLinear5D(_x, _y, _z, _a, _b, _c, feed) {
alert("Error", "Tool-Rotation detected - ESTLCAM only supports 3 Axis");
error("Tool-Rotation detected but ESTLCAM only supports 3 Axis");
}
function onCircular(clockwise, cx, cy, cz, x, y, z, feed) {
var start = getCurrentPosition();
if (isHelical()) {
linearize(tolerance);
return;
}
switch (getCircularPlane()) {
case PLANE_XY:
writeBlock(clockwise ? "G02" : "G03", xaOutput.format(x), yaOutput.format(y), zaOutput.format(z), iOutput.format(cx - start.x), jOutput.format(cy - start.y), feedOutput.format(feed));
break;
default:
linearize(tolerance);
}
}
function onSectionEnd() {
}
function onClose() {
writeBlock("G00", xOutput.format(0), yOutput.format(0));
}