Skip to content

Commit abe814e

Browse files
sharmstrsharmstr
andauthored
Changed naming convention of first file in multifile generation (#3)
* Update OpenbuildsFusion360PostGrbl.cps * Test * Renames first file in multifile generation to use 1 of # convention I tried to do this years ago, but it "open in nc editor" would open a log file instead of the first file. Finally figured out how to get it to open the first file. In order for it it work properly you need to untick "open in nc editor" which doesnt make any sense but it does work. Co-authored-by: sharmstr <[email protected]>
1 parent 4f394ac commit abe814e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

OpenbuildsFusion360PostGrbl.cps

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ 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
4445
*/
45-
obversion = 'V1.0.29';
46+
obversion = 'V1.0.30';
4647
description = "OpenBuilds CNC : GRBL/BlackBox"; // cannot have brackets in comments
4748
longDescription = description + " : Post" + obversion; // adds description to post library diaglog box
4849
vendor = "OpenBuilds";
@@ -508,14 +509,14 @@ function writeHeader(secID)
508509
}
509510
writeln("");
510511
511-
if (properties.generateMultiple)
512+
if (properties.generateMultiple && filesToGenerate > 1)
512513
{
513514
writeComment(numberOfSections + " Operation" + ((numberOfSections == 1) ? "" : "s") + " in " + filesToGenerate + " files.");
514515
writeComment("File List:");
515-
writeComment(" " + FileSystem.getFilename(getOutputPath()));
516-
for (var i = 0; i < filesToGenerate - 1; ++i)
516+
//writeComment(" " + FileSystem.getFilename(getOutputPath()));
517+
for (var i = 0; i < filesToGenerate; ++i)
517518
{
518-
filenamePath = FileSystem.replaceExtension(getOutputPath(), fileIndexFormat.format(i + 2) + "of" + filesToGenerate + "." + extension);
519+
filenamePath = FileSystem.replaceExtension(getOutputPath(), fileIndexFormat.format(i + 1) + "of" + filesToGenerate + "." + extension);
519520
filename = FileSystem.getFilename(filenamePath);
520521
writeComment(" " + filename);
521522
}
@@ -1274,11 +1275,14 @@ function onClose()
12741275

12751276
function onTerminate()
12761277
{
1277-
//The idea here was to rename the first file to <filename>.001ofX.nc so that when multiple files were generated, they all had the same naming conventionl
1278-
//While this does work, the auto load into Brackets loads a log file instead of the gcode file.
1279-
1280-
//var fileIndexFormat = createFormat({width:3, zeropad: true, decimals:0});
1281-
//FileSystem.moveFile(getOutputPath(), FileSystem.replaceExtension(getOutputPath(), fileIndexFormat.format(1) + "of" + filesToGenerate + ".nc"));
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+
}
12821286
}
12831287

12841288
function onCommand(command)

0 commit comments

Comments
 (0)