Thanks for your help. I have tried your suggestion - not sure exactly where the code belongs. So I have found in the Function onSection() the following code:
...
if (true ||
insertToolCall ||
isFirstSection() ||
(rpmFormat.areDifferent(spindleSpeed, sOutput.getCurrent())) ||
(tool.clockwise != getPreviousSection().getTool().clockwise)) {
if (spindleSpeed < 0) {
error(localize("Spindle speed out of range."));
return;
}
if (spindleSpeed > 99999) {
warning(localize("Spindle speed exceeds maximum value."));
}
if (spindleSpeed == 0) {
writeBlock(mFormat.format(5), c[0], c[1], c[2], c[3], formatComment("SPINDLE IS OFF"));
} else {
writeBlock(
sOutput.format(spindleSpeed), mFormat.format(tool.clockwise ? 3 : 4), c[0], c[1], c[2], c[3]
);
if ((spindleSpeed > 5000) && properties.waitForSpindle) {
onDwell(properties.waitForSpindle);
}
}
}
...
I have inserted your code in the following manner:
if (true ||
insertToolCall ||
isFirstSection() ||
(rpmFormat.areDifferent(spindleSpeed, sOutput.getCurrent())) ||
(tool.clockwise != getPreviousSection().getTool().clockwise)) {
if (spindleSpeed < 0) {
error(localize("Spindle speed out of range."));
return;
}
if (spindleSpeed > 99999) {
warning(localize("Spindle speed exceeds maximum value."));
}
if (spindleSpeed == 0) {
writeBlock(mFormat.format(5), c[0], c[1], c[2], c[3], formatComment("SPINDLE IS OFF"));
} else {
if (currentSection.isPatterned && currentSection.isPatterned() && getCurrentSectionId() > 0){
if (!(getPreviousSection().getPatternId() == currentSection.getPatternId())){
writeBlock(
sOutput.format(spindleSpeed), mFormat.format(tool.clockwise ? 3 : 4), c[0], c[1], c[2], c[3]
);
if ((spindleSpeed > 5000) && properties.waitForSpindle) {
onDwell(properties.waitForSpindle);
}
}
}
}
}
Unfortunately, that code did not output SxxxX M3 M8 anywhere in the NC file. It skipped that line everywhere...
I will show the current output and desired output in the new post.