I added the Code from the HAAS.cps post to the end of my_post.cps, which generates the nc code but does not trigger the set-up sheet. Am I missing a procedural call somewhere to the function onTerminate()?
I have verified that the excel.cps and setup sheet are in the same folder as the post.
Here is the last few functions from my post where I added at the end:
function onClose() {
writeln("");
optionalSection = false;
onCommand(COMMAND_COOLANT_OFF);
if (properties.gotChipConveyor) {
onCommand(COMMAND_STOP_CHIP_TRANSPORT);
}
if (getNumberOfSections() > 0) { // Retracting Z first causes safezone overtravel error to keep from crashing into subspindle. Z should already be retracted to and end of section.
var section = getSection(getNumberOfSections() - 1);
if ((section.getType() != TYPE_TURNING) && isSameDirection(section.workPlane.forward, new Vector(0, 0, 1))) {
writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(properties.g53HomePositionX), conditional(gotYAxis, "Y" + yFormat.format(properties.g53HomePositionY))); // retract
xOutput.reset();
yOutput.reset();
writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((currentSection.spindle == SPINDLE_SECONDARY) ? properties.g53HomePositionSubZ : properties.g53HomePositionZ)); // retract
zOutput.reset();
writeBlock(getCode("STOP_LIVE_TOOL"));
} else {
if (gotYAxis) {
writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(properties.g53HomePositionY)); // retract
}
writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(properties.g53HomePositionX)); // retract
xOutput.reset();
yOutput.reset();
writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? properties.g53HomePositionSubZ : properties.g53HomePositionZ)); // retract
zOutput.reset();
writeBlock(getCode("STOP_MAIN_SPINDLE"));
}
}
gMotionModal.reset();
cAxisEngageModal.reset();
writeBlock(getCode("DISENGAGE_C_AXIS"));
if (gotYAxis) {
writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(properties.g53HomePositionY));
yOutput.reset();
}
if (gotBarFeeder) {
writeln("");
writeComment(localize("Bar feed"));
writeBlock(mFormat.format(5));
// feed bar here
writeOptionalBlock(gFormat.format(105));
writeOptionalBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(properties.g53HomePositionX));
writeOptionalBlock(mFormat.format(1));
writeOptionalBlock(mFormat.format(99)); // restart
}
writeln("");
onImpliedCommand(COMMAND_END);
onImpliedCommand(COMMAND_STOP_SPINDLE);
if (true /*!properties.useM97*/) {
writeBlock(mFormat.format(30)); // stop program, spindle stop, coolant off
} else {
writeBlock(mFormat.format(99));
}
writeln("%");
}
// <<<<< INCLUDED FROM ../common/haas lathe.cps
properties.maximumSpindleSpeed = 3400;
gotYAxis = false;
yAxisMinimum = toPreciseUnit(gotYAxis ? -50.8 : 0, MM); // specifies the minimum range for the Y-axis
yAxisMaximum = toPreciseUnit(gotYAxis ? 50.8 : 0, MM); // specifies the maximum range for the Y-axis
xAxisMinimum = toPreciseUnit(0, MM); // specifies the maximum range for the X-axis (RADIUS MODE VALUE)
gotBAxis = false; // B-axis always requires customization to match the machine specific functions for doing rotations
gotMultiTurret = false; // specifies if the machine has several turrets
gotSecondarySpindle = false;
gotDoorControl = false;
gotBarFeeder = false;
function onTerminate() {
var outputPath = getOutputPath();
var programFilename = FileSystem.getFilename(outputPath);
var programSize = FileSystem.getFileSize(outputPath);
var postPath = findFile("setup-sheet-excel-2007.cps");
var intermdiatePath = FileSystem.replaceExtension(outputPath, "cnc");
var a = "--property unit 0"; // use 0 for inch and 1 for mm
if (programName) {
a += " --property programName \"'" + programName + "'\"";
}
if (programComment) {
a += " --property programComment \"'" + programComment + "'\"";
}
a += " --property programFilename \"'" + programFilename + "'\"";
a += " --property programSize \"" + programSize + "\"";
a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermdiatePath + "\" \"" + outputPath + ".xlsx\"";
execute(getPostProcessorPath(), a, false, "");
}