Updated: here’s a better one. Who knew that hp2xx had a gcode mode built in?
hp2xx -t -m nc -z 0 -Z 5 -f - file.hpgl | grep -v '^M0.' | sed 's/^G01/G0/;' | awk 'BEGIN {print "G21\nG90";} END {print "G0 Z5";} {print;}' > file.gcode
Aah, no: forget the stuff below.
hp2xx -t -m hpgl -f - phweeen.hpgl | sed 's/;/\n/g;' | grep -v '^SP' | grep -v PA | awk -F, 'BEGIN {print "G0X0Y0Z5";} /^PU/ {sub(/PU/, "", $1); printf("G0Z5\nG0X%fY%f\n", $1/40.0, $2/40.0);} /^PD/ {sub(/PD/, "", $1); printf("G0Z0\nG0X%fY%fZ0\n", $1/40.0, $2/40.0);} END {print "G0Z5";}' > ~/Desktop/phweeen.gcode
- likely targets a MidTBot a little too much
- ignores pen changes
- assumes pen up means tool Z=5 and pen down means tool Z=0
- only understands PU (move) and PD (draw) commands
- requires hp2xx
- tested with trivially few sample files exported as HP-GL from Inkscape
- doesn’t care about paper size; your plotter does, though.