Skip to content

Commit 54354a5

Browse files
committed
.32 tweaks to fix long comments
1 parent 6523a69 commit 54354a5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

OpenbuildsFusion360PostGrbl.cps

+9-8
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ Changelog
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
4444
10 May 2022 - V1.0.30 : Change naming convention for first file in multifile output (Sharmstr)
4545
xx Sep 2022 - V1.0.31 : better laser, with pierce option if cutting
46+
06 Dec 2022 - V1.0.32 : fix long comments that were getting extra brackets
4647
*/
47-
obversion = 'V1.0.31';
48+
obversion = 'V1.0.32';
4849
description = "OpenBuilds CNC : GRBL/BlackBox"; // cannot have brackets in comments
4950
longDescription = description + " : Post" + obversion; // adds description to post library dialog box
5051
vendor = "OpenBuilds";
@@ -440,34 +441,34 @@ function myMachineConfig()
440441
}
441442
}
442443
444+
// Remove special characters which could confuse GRBL : $, !, ~, ?, (, )
445+
// In order to make it simple, I replace everything which is not A-Z, 0-9, space, : , .
446+
// Finally put everything between () as this is the way GRBL & UGCS expect comments
443447
function formatComment(text)
444448
{
445449
return ("(" + filterText(String(text), permittedCommentChars) + ")");
446450
}
447451
448452
function writeComment(text)
449453
{
450-
// Remove special characters which could confuse GRBL : $, !, ~, ?, (, )
451-
// In order to make it simple, I replace everything which is not A-Z, 0-9, space, : , .
452-
// Finally put everything between () as this is the way GRBL & UGCS expect comments
453454
// v20 - split the line so no comment is longer than 70 chars
454455
if (text.length > 70)
455456
{
456457
//text = String(text).replace( /[^a-zA-Z\d:=,.]+/g, " "); // remove illegal chars
457-
text = formatComment(text);
458+
text = filterText(text.trim(), permittedCommentChars);
458459
var bits = text.split(" "); // get all the words
459460
var out = '';
460461
for (i = 0; i < bits.length; i++)
461462
{
462-
out += bits[i] + " ";
463+
out += bits[i] + " "; // additional space after first line
463464
if (out.length > 60) // a long word on the end can take us to 80 chars!
464465
{
465-
writeln("(" + out.trim() + ")");
466+
writeln(formatComment( out.trim() ) );
466467
out = "";
467468
}
468469
}
469470
if (out.length > 0)
470-
writeln("(" + out.trim() + ")");
471+
writeln(formatComment( out.trim() ) );
471472
}
472473
else
473474
writeln(formatComment(text));

0 commit comments

Comments
 (0)