04-21-2023
12:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
04-21-2023
12:13 AM
/** Output block to do safe retract and/or move to home position. */
var XZ = 4;
function writeRetract() {
var words = []; // store all retracted axes in an array
var singleLineRetract = false;
var retractAxes = []; // axes to retract
var method = getProperty("safePositionMethod");
// define home positions
var _xHome;
var _yHome;
var _zHome;
_xHome = machineConfiguration.hasHomePositionX() ? machineConfiguration.getHomePositionX() : getProperty("homePositionX");
_yHome = machineConfiguration.hasHomePositionY() ? machineConfiguration.getHomePositionY() : toPreciseUnit(0, MM);
_zHome = machineConfiguration.getRetractPlane() != 0 ? machineConfiguration.getRetractPlane() : getProperty("homePositionZ");
// end of changes if (arguments.length > 0) {
for (var i in arguments) {
retractAxes.push(arguments[i]);
singleLineRetract = arguments[i] == XZ ? true : singleLineRetract;
}
} else {
switch (getProperty("safePositionStyle")) {
case "X":
retractAxes.push(X);
break;
case "Z":
retractAxes.push(Z);
break;
case "XZ":
retractAxes.push(X, Z);
break;
case "ZX":
retractAxes.push(Z, X);
break;
case "singleLineXZ":
singleLineRetract = true;
retractAxes.push(X, Z);
break;
}
}
// format home positions
for (var i = 0; i < retractAxes.length; ++i) {
switch (retractAxes[i]) {
case X:
words.push((method == "G28" ? "U" : "X") + xFormat.format(_xHome));
retracted[X] = true;
xOutput.reset();
break;
case Y:
if (yOutput.isEnabled()) {
words.push((method == "G28" ? "V" : "Y") + yFormat.format(_yHome));
yOutput.reset();
}
break;
case Z:
words.push((method == "G28" ? "W" : "Z") + zFormat.format(_zHome));
retracted[Z] = true;
zOutput.reset();
break;
case XZ:
words.push((method == "G28" ? "U" : "X") + xFormat.format(_xHome));
words.push((method == "G28" ? "W" : "Z") + zFormat.format(_zHome));
retracted[X] = true;
retracted[Z] = true;
xOutput.reset();
zOutput.reset();
break;
default:
error(localize("Unsupported axis specified for writeRetract()."));
return;
}
}
for (var i = 0; i < words.length; ++i) {
switch (method) {
case "G28":
gAbsIncModal.reset();
writeBlock(gFormat.format(28), singleLineRetract ? words : words[i]);
break;
case "G53":
gMotionModal.reset();
writeBlock(gFormat.format(53), gMotionModal.format(0), singleLineRetract ? words : words[i]);
break;
default:
error(localize("Unsupported safe position method."));
return;
}
if (singleLineRetract) {
break;
}
}
singleLineRetract = false; // singleLineRetract reset
}
Fusion