Export to plot not handling pen change correctly

Steps to reproduce:

  • open Inkscape
  • Create and export to plot a multi pen plot with the Extensions-Export-Plot This is NOT the same as saving a .svg as .plt as this does not respect pen layers You will need to do a serial dump to see what is going on ( or hook up a plotter )

What happened?

On pen change the plotter will return to the end of the previous path and make a single pen down - pen up movement before moving onto the beginning of the new path leaving a single dot from the new pen on the old path

What should have happened?

The pen should move to the beginning of the new path and start plotting without first making a dot on the old path

Inkscape Version and Operating System:

  • Inkscape Version: ... Inkscape 0.92.4 (5da689c313, 2019-01-14)
  • Operating System: … Windows 10
  • Operating System version: … 1904
Example file:

This is what is currently produced IN;FS2;SP1;PU2249,2395;PD2249,3517,3476,3517,3476,2395,2249,2395;SP2;PU2249,2395;PD2249,3517,3476,3517,3476,2395,2249,2395;SP3;PU2249,2395;PD2249,3517,3476,3517,3476,2395,2249,2395;PU;SP0;0,0;

This is what should be produced (note the PU; command before the ;SP) IN;FS2;PU;SP1;2249,2395;PD2249,3517,3476,3517,3476,2395,2249,2395;PU;SP2;2249,2395;PD2249,3517,3476,3517,3476,2395,2249,2395;PU;SP3;2249,2395;PD2249,3517,3476,3517,3476,2395,2249,2395;PU;SP0;0,

To Note:

HPGL remembers the last pen state before each pen change. If the pen change command directly follows a pen down movement, then the new pen will first try to resume the previous pen sate ( down ) before receiving commands to lift pen and move to beginning of new path. The result is a dot at the end of the old path from the new pen

Possible Solution

https://gitlab.com/inkscape/extensions/-/blob/master/hpgl_encoder.py#L342

self.hpgl += ';PU;SP%d' % pen

Not the most elegant solution, but the simplest