3D Printing on the commandline

2019-03-09

(3DPrinting)

My first attempt at 3D printing was connecting directly from a laptop running MatterControl to my printer. Halfway through my first serious print MatterControl crashed on me, making me realise I didn't want to have my print job relying on me having my laptop connected to it running some complex software that might interact badly with other complex software.

The first thing I tried was OctoPrint on a Raspberry Pi with the OctoPi SD card image. OctoPrint is awesome software that served me well for a year or more. If you want to leave your prints unattended in the garage I highly recommend getting a Raspberry Pi and running OctoPi on it.

After a house renovation and a 6 month break from printing I fired up my OctoPi to get something printed for a friend. The SD card was fried (cheap SD cards suck, don't be cheap like me) and I was faced with the prospect of setting up OctoPi again and getting everything configured. Luckily I had backed up my profiles but I hesitated.

Despite really liking OctoPi there are a few things about it that I just couldn't be bothered with:

  • It was handy to slice on the device in the beginning, but slicing was slow and slicing can be done on a more powerful computer.
  • The interface is really nice, but on a Raspberry Pi it's not super responsive. But I don't really need a UI. The support for the camera was cool, but I don't need to see graphs of temperatures, or watch the extruding path in real-time. All I really want is a percentage progress so I know approximately when it's gonna be done.
  • I prefer commandline tools because they are light weight, can be executed remotely over ssh and I can fire long running things up in screen and not worry about loosing the network.

So with that in mind I set myself up with a commandline only print system.

Slicing

I chose Slic3r because it has an awesome commandline mode. You can convert Cura profiles to commandline parameters fairly easily and then write a bash script to automate things for you. I ended up with a slic3r-prusa.sh script that runs Slic3r with my machine settings. On my laptop it takes a couple of seconds to slice something relatively complex.

Printing

After some searching around I found pronsole.py which comes with PrintRun. Printrun has a bunch of GUI tools and I didn't want those so I extracted the parts I needed to run prosole and wrapped that in a Makefile in case I need it in the future:

FILES =
FILES += pronsole.py
FILES += printrun/pronsole.py
FILES += printrun/printcore.py
FILES += printrun/gcoder.py
FILES += printrun/gcoder_line_extra.h
FILES += printrun/gcoder_line.pyx
FILES += printrun/utils.py
FILES += printrun/plugins/__init__.py
FILES += printrun/settings.py
FILES += printrun/power/__init__.py
FILES += printrun/rpc.py
FILES += printrun/spoolmanager/__init__.py
FILES += printrun/spoolmanager/spoolmanager.py

DEPS =
DEPS += python3-appdirs
DEPS += python3-serial
DEPS += python3-psutil

all: deps clone package test

clone:
    git clone https://github.com/kliment/Printrun.git

package:
    cd Printrun/ && tar -czvf ../pronsole.tgz $(FILES)

deps:
    sudo apt-get install $(DEPS)

test: package
    tar -xzvf pronsole.tgz
    python3 pronsole.py

clean:
    rm -rf Printrun pronsole.tgz printrun pronsole.py

So now I have my Raspberry Pi running connected to the network and the printer. I can log in over ssh and fire up screen and run pronsole.py to do the print.

Happy printing!