abey79 / vpype

The Swiss-Army-knife command-line tool for plotter vector graphics.
https://vpype.readthedocs.io/
MIT License
699 stars 61 forks source link

Allow arbitrary paper size in `write` #23

Closed abey79 closed 4 years ago

abey79 commented 4 years ago

Easy way: add a custom option --page-format and a --paper-size parameter.

Additionally, --page-format could be made to automatically recognise AxB pattern for inch-sized paper.

cc @jbum

ithinkido commented 4 years ago

When plotting with a HP7440 plotter I have found a page definition of 190x270mm is about the max size that can be plotted. The home position is defined as the top left corner of this area. If you have setup a drawing in a defined page size, it would be good if it was possible to preserve the page size when using vpype unless otherwise defined by the write --page-format or --paper-size parameter. This way the drawing would remain in the same position relative to the zero point and plott as planned

I would find this a good addition to this theme ---preserve-page-size

abey79 commented 4 years ago

Can you clarify you entire workflow? Are you exporting SVG from vpype and then loading it to another software to convert to HPGL? If so, can you tell me which one?

Also, what do you mean by "top left" corner? Coordinates at (0, 270mm)?

ithinkido commented 4 years ago

At the moment, I have a bunch of designs that I set up on the page format of 190x270 so that the plotted position would be as planned. After the first plotts I realized that the path optimization was not ideal so I fed them into vpype to fix. After that I import the svg back to inkscape and would normaly export to plot from Inkscape.
When I get the drawing back from vpype the page dimensions are adjusted to the size of the drawing so that if i was to plot directly it would align the new drawing and start plotting it from the machine zero point, ie on my machine top left corner.

abey79 commented 4 years ago

So if I understand it correctly, assuming there would be a way to specify a custom page format in the write command, you could work around the issue by using it and specifying (again) 192x270, right? Something like the following (--page-format doesn't currently accept arbitrary page size:

$ vpype read input.svg [... optimisation commands...] write --page-format 192x270mm

In the mean time and as an immediate workaround, I can also offer the following:

$ vpype read input.svg [... optimisation commands...] line -l new 0 0 190mm 270mm write output.svg

This way, output.svg will be at least 190x270mm, but will contain an additional layer with a diagonal line. Maybe it's easier for you to delete/ignore this layer rather than resizing the document.

ithinkido commented 4 years ago

The first option is what i would be most interested in. Write --page -- format -- any size you like I think the problem here is that the plotter is using relative coordinates so that changes to page size mean changes to the page layout

abey79 commented 4 years ago

OK. Option 1 is relatively high on the todo list. Option 2 is a workaround, but is available right now :)

ithinkido commented 4 years ago

Ok , thanks, I look forward to the definable page sizes.

abey79 commented 4 years ago
Usage: vpype write [OPTIONS] OUTPUT

  Save geometries to a SVG file.

  By default, the SVG generated has bounds tightly fitted around the
  geometries. Optionally, a page format can be provided with the `--page-
  format FORMAT` option. `FORMAT` may be one of:

      tight, a6, a5, a4, a3, letter, legal, executive

  Alternatively, a custom format can be specified in the form of
  `WIDTHxHEIGHT`. `WIDTH` and `HEIGHT` may include units. If only one has an
  unit, the other is assumed to have the same unit. If none have units, both
  are assumed to be pixels by default. Here are some examples:

      --page-format 11x14in     # 11in by 14in
      --page-format 1024x768    # 1024px by 768px
      --page-format 13.5inx4cm  # 13.5in by 4cm

  When a page format is provided, it will be rotated if the `--landscape`
  option is used.

  By default, when a page format is provided, the geometries are not scaled
  or translated even if they lie outside of the page bounds. The `--center`
  option translates the geometries to the center of the page.

  If `OUTPUT` is a single dash (`-`), SVG content is output on stdout
  instead of a file.

  Examples:

      Write to a tightly fitted SVG:

          vpype [...] write output.svg

      Write to a portrait A4 page:

          vpype [...] write --page-format a4 output.svg

      Write to a 13x9 inch page and center the geometries:

          vpype [...] write --page-format 13x9in --landscape --center
          output.svg

      Output SVG to stdout:

          vpype [...] write -

Options:
  -s, --single-path           Generate a single compound path instead of
                              individual paths.

  -p, --page-format PAGESIZE  Set the bounds of the SVG to a specific page
                              format. If omitted, the SVG size it set to the
                              geometry bounding box.

  -l, --landscape             Use landscape orientation instead of portrait.
  -c, --center                Center the geometries within the SVG bounds
  --help                      Show this message and exit.