Skip to content

Commit f177c6f

Browse files
committed
new onterminate from sharmstr to remove error message on file open after post
1 parent abe814e commit f177c6f

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

OpenbuildsFusion360PostGrbl.cps

+29-18
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ Changelog
4141
12 Nov 2021 - V1.0.28 : Added property group names, fixed default router selection, now uses permittedCommentChars (sharmstr)
4242
24 Nov 2021 - V1.0.28 : Improved coolant selection, tweaked property groups, tweaked G53 generation, links for help in comments.
4343
21 Feb 2022 - V1.0.29 : Fix sideeffects of drill operation having rapids even when in noRapid mode by always resetting haveRapid in onSection
44-
10 May 2022 - V1.0.30 : Change naming convention for first file in multifile output
44+
10 May 2022 - V1.0.30 : Change naming convention for first file in multifile output (Sharmstr)
4545
*/
4646
obversion = 'V1.0.30';
4747
description = "OpenBuilds CNC : GRBL/BlackBox"; // cannot have brackets in comments
48-
longDescription = description + " : Post" + obversion; // adds description to post library diaglog box
48+
longDescription = description + " : Post" + obversion; // adds description to post library dialog box
4949
vendor = "OpenBuilds";
5050
vendorUrl = "https://openbuilds.com";
5151
model = "GRBL";
@@ -317,7 +317,8 @@ function rpm2dial(rpm, op)
317317
var speeds = [0, 10000, 14000, 18000, 23000, 27000, 32000];
318318
}
319319
else
320-
{ // this is Makita R0701
320+
{
321+
// this is Makita R0701
321322
var speeds = [0, 10000, 12000, 17000, 22000, 27000, 30000];
322323
}
323324
if (rpm < speeds[1])
@@ -400,7 +401,7 @@ function writeBlock()
400401
401402
/**
402403
Thanks to nyccnc.com
403-
Thanks to the Autodesk Knowledge Network for help with this at
404+
Thanks to the Autodesk Knowledge Network for help with this at
404405
https://knowledge.autodesk.com/support/hsm/learn-explore/caas/sfdcarticles/sfdcarticles/How-to-use-Manual-NC-options-to-manually-add-code-with-Fusion-360-HSM-CAM.html!
405406
*/
406407
function onPassThrough(text)
@@ -771,15 +772,15 @@ function gotoInitial(checkit)
771772
if (debug) writeComment("gotoInitial end");
772773
}
773774

774-
// write a G53 Z retract
775+
// write a G53 Z retract
775776
function writeZretract()
776777
{
777778
zOutput.reset();
778779
writeln("(This relies on homing, see https://openbuilds.com/search/127200199/?q=G53+fusion )");
779780
writeBlock(gFormat.format(53), gMotionModal.format(0), zOutput.format(toPreciseUnit( properties.machineHomeZ, MM))); // Retract spindle to Machine Z Home
780781
gMotionModal.reset();
781782
zOutput.reset();
782-
}
783+
}
783784

784785

785786
function onSection()
@@ -791,7 +792,7 @@ function onSection()
791792
var maxfeedrate = section.getMaximumFeedrate();
792793
if (debug) writeComment("onSection " + sectionId);
793794
haveRapid = false; // drilling sections will have rapids even when other ops do not
794-
795+
795796
onRadiusCompensation(); // must check every section
796797
797798
if (isPlasma)
@@ -923,8 +924,9 @@ function onSection()
923924
{
924925
writeZretract();
925926
}
926-
else if (properties.generateMultiple && (tool.number != getPreviousSection().getTool().number))
927-
writeZretract();
927+
else
928+
if (properties.generateMultiple && (tool.number != getPreviousSection().getTool().number))
929+
writeZretract();
928930

929931
gotoInitial(true);
930932

@@ -1059,7 +1061,7 @@ function onRapid(_x, _y, _z)
10591061

10601062
function onLinear(_x, _y, _z, feed)
10611063
{
1062-
//if (debug) writeComment("onLinear " + haveRapid);
1064+
//if (debug) writeComment("onLinear " + haveRapid);
10631065
if (powerOn || haveRapid) // do not reset if power is off - for laser G0 moves
10641066
{
10651067
xOutput.reset();
@@ -1275,14 +1277,23 @@ function onClose()
12751277

12761278
function onTerminate()
12771279
{
1278-
// If we are generating multiple files, then rename first file to add # of #
1279-
// If you dont want to show the log file, then untick "open in Open file in NC editor"
1280-
if (filesToGenerate > 1) {
1281-
var fileIndexFormat = createFormat({ width: 2, zeropad: true, decimals: 0 });
1282-
var newOutput = FileSystem.replaceExtension(getOutputPath(), fileIndexFormat.format(1) + 'of' + filesToGenerate + '.' + extension);
1283-
FileSystem.moveFile(getOutputPath(), newOutput);
1284-
executeNoWait(newOutput, '', false, '');
1285-
}
1280+
// If we are generating multiple files, copy first file to add # of #
1281+
// Then remove first file and recreate with file list - sharmstr
1282+
if (filesToGenerate > 1)
1283+
{
1284+
var outputPath = getOutputPath();
1285+
var outputFolder = FileSystem.getFolderPath(getOutputPath());
1286+
var programFilename = FileSystem.getFilename(outputPath);
1287+
FileSystem.copyFile(outputPath, FileSystem.replaceExtension(outputPath, fileIndexFormat.format(1) + 'of' + filesToGenerate + '.' + extension));
1288+
FileSystem.remove(outputPath);
1289+
var file = new TextFile(outputFolder + "\\" + programFilename, true, "ansi");
1290+
file.writeln("The following gcode files were created: ");
1291+
for (var i = 0; i < filesToGenerate; ++i)
1292+
{
1293+
file.writeln(programName + '.' + fileIndexFormat.format(i + 1) + 'of' + filesToGenerate + '.' + extension);
1294+
}
1295+
file.close();
1296+
}
12861297
}
12871298

12881299
function onCommand(command)

0 commit comments

Comments
 (0)