gcode comment alert in OpenBuilds Control

Have you ever wanted to display a message when you load a gcode file in OpenBuilds CONTROL? Here’s a quick and dirty javascript macro that will show a gcode alert.

function alertMacro() {
  editor.session.on('change', function(e) {
    if (editor.curOp && editor.curOp.command.name) {
      return null;
    let foundAlert = editor.find('ALERT:');
    if (foundAlert !== undefined) {
      let alertText = editor.session.getLine(foundAlert.start.row);
      console.log('what is pos ' + alertText)    
      var dialog = Metro.dialog.create({
        clsDialog: 'dark',
        title: "<i class='fas fa-exclamation-triangle'></i> ALERT",
        content: "<i class='fas fa-exclamation-triangle fg-darkRed'></i> " + alertText,
        actions: [{
          caption: "Close",
          cls: "js-dialog-close",
          onclick: function() {
$(document).ready(() => setTimeout(alertMacro, 1000));

Add the code to a new javascript macro and set it to run at startup. Restart CONTROL.

The macro looks for a string, in this case “ALERT:”, in your loaded gcode file. If it finds it, it will pop up a dialog box that displays the string.

Sample gcode file:

G90 G94 G17
(ALERT: Do something!)
G53 G0 Z-0.3937
G0 X-0.3937 Y-0.3937

In Fusion 360, you can add this comment with a manual nc comment operation: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID895129FD-6548-414D-8B31-EDBCC5EF4439

If you are new to OpenBuilds CONTROL, be sure to check out my OpenBuilds CONTROL tutorial.

OpenBuilds Products I Use (affiliate):

OpenBuilds CONTROL​
Workbee 1510​ (similar to Lead 1010 or Lead 1515)
BlackBox Motion Controller​
BlackBox X32 Motion Controller
Interface CNC Touch Controller​
XYZ Touch Probe Plus


Leave a reply

Your email address will not be published. Required fields are marked *


©2024 Thayne Co


I'm not around right now. But you can send me an email and I'll get back to you, asap.


Log in with your credentials


Forgot your details?

Create Account