Javascript / Expressions

Allows Gcode to execute javascript. Please note the German version is the original!


[ ] are expressions that are evaluated. The scripting language used is Javascript. So you can do almost everything that is possible in Javascript, but is limited to one line. Functions that have to span several lines are compressed by minifier ” become.

Save variable: [var start_x = 5;] Use of variable: G0 X[start_x]

Calculate:G0 X[50+22.5] Y[50/10]Calculate:G0 X[Math.sin(90 * Math.PI / 180)]


Functions must always be in one line. The easiest way to achieve this is a minifier .

Hello World

function runHello(number) {
dialog.addInfo("Hello World " + number);;


minified Hello World

function runHello(o){dialog.addInfo("Hello World "+o),}

If you now want to execute these lines, type :

[function runHello(o){dialog.addInfo(“Hello World “+o),}]

into the Gcode input
A dialog with “Hello World 255” should appear.


The dialog extension allows the user to display information as well as create input fields.

  • dialog.addInfo(info)
  • String : info

  • dialog.addInput(variable,inputname)
  • String : variable
    String : inputname

    variable specifies the name in which the input value is stored. Bspdialog.addInput(“x”,”max X: “). Shows “max X:” as an input field and saves the value using var x = value.

  • dialog.addInput(variable,inputname,default)
  • String : variable
    String : inputname
    String : default

    As above, only a default value is displayed.

  • )
  • Shows the dialog. When closing, possible variables are set and info/input fields are deleted.


The save extension allows the user to save custom variables permanently. These are loaded when the software is started.

  • String : variable
    String: value

    Example: var x = 55;and with“test”,x) the value 55 for test is saved in the permanent file. The variable test is not created directly, var test = 55 is only executed with data.load().

  • data.load()
  • Loads all variables stored in the permanent file.


    Variables that correspond to the settings of the milling machine. Changing these variables does not change anything in the real settings.

    • machine.x
    • machine.y
    • machine.z
    • Machine width(x)/ length(y) / height(z) positive values ​​

    • last_probe_.x
    • last_probe_.y
    • last_probe_.z
    • last_probe_.valid
    • X/Y/Z position of last probe operation, valid indicates if probe is valid.

    • toolchange.x
    • toolchange.y
    • toolchange.z
    • toolchange.enable
    • Tool change position stored in settings/gcode. enable indicates whether the tool change is activated.


    length sensor / probe

    Performs a probe towards minimum Z height. The variable machine.z is used for this. The sample position is displayed in a dialog.

    G38.2Z[-machine.z] F100
    [dialog.addInfo("Probe X:" + last_probe_.x + " Y:" + last_probe_.y + " Z:" + last_probe_.z )]

    Measures the time how long a Gcode took and gives a dialog at the end showing the total time taken as from the current file. The code must be inserted in the settings/Gcode pre and post Gcode

    Pre Gcode
    [var start_time = new Date();]

    Post Gcode
    [var end_time = new Date();]
    [var timeDiff = end_time - start_time; //in ms]
    [ var time_string = new Date(timeDiff ).toISOString().substr(11, 8)]
    [dialog.addInfo("The file required " + time_string + " ")][var gcode_time = gcode_time ? gcode_time + timeDiff : timeDiff]
    [ var time_string = new Date(gcode_time ).toISOString().substr(11, 8)]
    [dialog.addInfo("Total Gcode time " + time_string + " ")]
    Dialog / Customizable Gcode

    In this example, the user is prompted for the width and height of a rectangle. This is followed after clicking Next.

    [dialog.addInfo("This Gcode is traversing a rectangle.")]
    [dialog.addInput("r_width","Width: ","50")]
    [dialog.addInput("r_heigth","Height: ","25")]
    G0 G91 X[r_width]
    G0 G91 Y[r_height]
    G0 G91 X[-r_width]
    G0 G91 Y[-r_height]
    More ideas

    Detect if the tool has been damaged : When the cutter is measured, store the Z value and measure again after use and compare the value. If the value deviates too much, move to a safe position, stop the spindle and pause with M0. This could be inserted directly into the ToolGcode for an automatic tool change spindle.

    Time measurements: how long was the cutter used /how long did the milling process take

    Save your todo list for next time.

    Tap: Set to zero probe is run in Z X Y.

    If further variables or options are desired, mail to