Skip to content
Jeff Siddall edited this page Jul 13, 2023 · 14 revisions

bCNC allow to use python inside gCode. Prefix a line with the % symbol and the line will be evaluated by the sender.

There are some special directives:

  • %wait : empty and wait the grbl buffer. It will pauses the internal sender until all commands up to this point are completed, grbl return "ok" and the Rx grbl buffer is empty.
  • %if running : executed only when code is streamed to grbl. Not during editing.
  • %msg :
  • %update :
  • %import os; os.system("xterm")
  • %import sys; print("enter value: "); _myval=sys.stdin.readline(); print("value: "+_myval);
  • %_myval=raw_input("enter value: "); print("entered value: "+_myval);
  • %_myval=app.entry("enter diameter")
  • G0 X10 Y[_myval] : access to internal variables
  • %print("hello world")
  • %app.setStatus("hello world") : update bCNC status bar
  • #nnn : access to internal variables
  • SENDHEX 42 : send 0x42 char

Interactive g-code!

Now you can ask user to enter values during g-code execution via popup:

Or via commandline:

User Buttons

User configurable buttons in the Control tab can also have scripting. When using buttons be sure to prefix anything that starts with with the % symbol with two %% symbols.

Clone this wiki locally