- Python 38%
- TypeScript 37%
- Nix 25%
- CSS <1%
- JavaScript <1%
- 1 more language <1%
Bambu Plotter #
Turn a Bambu Lab printer into a pen plotter, with a page that tells you what to do at each step: when to put the pen in, how to set its height, and where the paper is on the bed.
Draw handwritten-style text (letters, poems) with a font, size and bold, italic or underline for each word, trace PNG/JPEG images, or plot SVGs. The paper preview shows exactly what the pen will draw; drag it to move, resize or turn the drawing.
Running it #
bun install
uv run fastapi dev app/main.py
Open http://localhost:8000. The Vite dev server is started for you.
To try it without a printer, run it in simulated mode. G-code is printed to the terminal instead of being sent:
BAMBU_PLOTTER_FAKE=1 uv run fastapi dev app/main.py
NixOS #
The flake has a package and a module:
# flake.nix inputs
bambu-plotter.url = "github:patrick91/bambu-plotter";
# configuration
imports = [ bambu-plotter.nixosModules.default ];
services.bambu-plotter = {
enable = true;
port = 8002; # listens on 127.0.0.1; put a proxy in front
};
The page has no login and moves your printer, so keep it off the internet.
Settings live in /var/lib/bambu-plotter.
Python dependencies come from uv.lock. Frontend dependencies come from
bun.nix, which bun install regenerates from bun.lock; commit it with the
lock file.
The printer #
- Turn on LAN Only mode and Developer mode on the printer. The IP address and access code are on the same screen.
- Settings are saved to
~/.config/bambu-plotter/settings.json. On first run they're imported from bambucuts'~/.bambucuts.confif it exists. - Tested in simulation with the A1 mini bed size; A1 and P1 bed sizes are available too.
How it works #
The printer doesn't report where its head is, so the app keeps track of it from the G-code it sends:
- Home X/Y. After this the head position is known (the head is parked in the middle of the bed). Z is never homed, because homing Z would drive the nozzle (and the pen next to it) into the bed.
- Pen height. You lower the pen until it touches the paper and the app
calls that Z=0. The pen travels
Liftmm above it and draws atPressmm below it. - Paper corners. You move the pen tip over the paper's top-left (and bottom-right) corner. Corners are recorded where the pen is, so the pen's offset from the nozzle never matters.
Plots are sent over MQTT as gcode_line commands in chunks of about 150 lines.
Each chunk ends with an M73 P<n> marker, which the printer echoes back as
mc_percent once it gets there. That's how progress is tracked, and how
stopping works: no more chunks are sent, and the pen is lifted once the ones
already queued have run.
Approach and protocol details are borrowed from bambu-cuts.
Layout #
app/printer.py: MQTT connection, moves, head tracking, the plot runnerapp/design.py: text (Hershey single-stroke fonts), SVG and image tracing to strokesapp/plot.py: layout on the paper, stroke ordering, G-codeapp/camera.py: snapshots from the printer camerafrontend/: the React page (Inertia)