Author Topic: HPGL language: SW to convert polygons to set of parallel lines?  (Read 2018 times)

0 Members and 1 Guest are viewing this topic.

Offline hanakpTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: cz
HPGL language: SW to convert polygons to set of parallel lines?
« on: October 05, 2024, 07:32:15 pm »
A friend has working HP 7475A pen plotter and we tried to feed it some HPGL files. It mostly works, but we've run into some trouble when when the drawings contain filled areas. Old programs generated a set of parallel lines to fill them, usually aligned with the longest edge of the area. More modern HPGL files frequently contain polygon instructions PM, EP and FP which allow the plotter to fills the areas on its own, based on pen thickness (PT) value. However, these instructions are not supported by 7475A. Back in 1990s, there were at least dozen commercial programs that could view, edit or duplicate/panelize HPGL files. Most are lost to history now, so I want to ask: could any of them convert polygons to set of parallel lines? I found PloView, but it seems it doesn't have such function.
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 7088
  • Country: fi
    • My home page and email address
Re: HPGL language: SW to convert polygons to set of parallel lines?
« Reply #1 on: October 05, 2024, 10:33:57 pm »
HPGL is still used with vinyl cutters, although fills aren't an issue there.  I know free, open source hp2xx tool can do it (hp2xx-3.5.0a35, using hp2xx -m hpgl -f out.plt in.plt), but its polygon fill routine is imperfect in certain corner cases.

Note that free, open source Inkscape can read and save HPGL files, but as it is geared towards vinyl cutters, it doesn't do fills.
 

Offline Someone

  • Super Contributor
  • ***
  • Posts: 5067
  • Country: au
    • send complaints here
Re: HPGL language: SW to convert polygons to set of parallel lines?
« Reply #2 on: October 05, 2024, 11:38:41 pm »
Inkscape has a variety of extensions, no idea if they are current but examples come up from the keyword "hatch"
https://alpha.inkscape.org/vectors/www.inkscapeforum.com/viewtopica123.html?t=34704
 

Offline hanakpTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: cz
Re: HPGL language: SW to convert polygons to set of parallel lines?
« Reply #3 on: October 15, 2024, 11:03:26 pm »
I tried the hp2xx utility, but I didn't get very far.

-Version 3.4.4 is 20 years old and its Windows binary doesn't run on Windows 10.

-Version 3.4.4 for Linux works and indeed can convert HPGL with polygons. But it unnecessarily generates hundreds of lines, it converts 60 KB polygon HPGL into 2 MB line HPGL. The output file displays fine in a viewer, but is unusable for actual pen plotter. Setting the -p switch to define pen width doesn't help.

HPGL is still used with vinyl cutters, although fills aren't an issue there.  I know free, open source hp2xx tool can do it (hp2xx-3.5.0a35, using hp2xx -m hpgl -f out.plt in.plt), but its polygon fill routine is imperfect in certain corner cases.

I tried the 3.5.0 version, but it can't be compiled due to syntax errors (looks like current GCC has more stringent rules). Several other people reported them over the years on Github, but it seems the project is dead. Do you have a working Linux or Windows binary you could share?
« Last Edit: October 15, 2024, 11:09:12 pm by hanakp »
 

Offline hanakpTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: cz
Re: HPGL language: SW to convert polygons to set of parallel lines?
« Reply #4 on: October 16, 2024, 10:03:44 pm »
So hp2xx 3.5.0 isn't dead after all, one of the authors commited necessary fixes a few hours ago. The 3.5.0 version indeed works better than 3.4.4, output HPGL file has only 400 KB now. But it still doesn't obey pen thickness, resulting in hundreds of lines. Moreover, the lines are always horizontal, not aligned with the longest edge on the polygon. That increases their numbers even more. I'm attaching a screenshot from CERN HPGL Viewer that shows it.

Another oddity is that hp2xx scales all input plots to 200 mm width by defaut. To preserve scale of the original drawing, I had to use -t switch. But using the switch had minimal effect on number of lines in the output HPGL, file size was almost the same.

In case someone wants to fiddle with it, I'm also attaching test HPGL file. It contains a single polygon, it's a diagonal line 14.1 mm long (drawn in 10x10 mm grid) and 1 mm thick, pen thickness is set to 0.3 mm. It has 251 bytes. I'm also attaching output files from hp2xx 3.5.0, but they always have about 25 KB, regardless of -t or -p settings. They were generated with command

hp2xx -t -m hpgl -p 33333333 -f out.plt onepoly.plt

I also checked out Inkscape, but it looks... daunting.
« Last Edit: October 16, 2024, 10:16:43 pm by hanakp »
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 7088
  • Country: fi
    • My home page and email address
Re: HPGL language: SW to convert polygons to set of parallel lines?
« Reply #5 on: October 21, 2024, 10:14:29 am »
A friend of mine used to maintain and develop Tux Plot, dedicated for working on HPGL files for plotters, vinyl cutters, plasma tables and so on, but ever since Covid, I haven't gotten hold of him anymore, and even his website is down, so I fear the worst.



The question is, do you want to work with HPGL throughout, or use a more modern vector format like SVG for the artwork, and only convert to HPGL as the final step?  That is, there is no reason to work in HPGL, just because your plotter uses HPGL.  You can work in any vector format you like, and simply convert the final artwork to HPGL when plotting.

You can do your own HPGL processing in Python using e.g. Chiplotle3 library.  It does not have a function for converting fills to lines or hatching, so that you would need to add yourself.  Polygon or path filling with parallel lines is surprisingly easy math (although easy to get wrong, if you aren't aware of the corner cases).

Similarly, one can do an Inkscape extension in Python for customized HPGL export.

However, if you use SVG and Inkscape for processing your artwork, you can use existing extensions, for example built-in GcodeTools > Area..., or if you install Eggbot extensions, its Hatch fill....  Or, you can create a suitable fill first, using e.g. Extensions > Render > Grids > (any), then move the fill hatch below the object you want to fill, select both, and then Path > Fracture or Break apart, and delete any excess fill lines left.

In other words, you can use Inkscape to generate and edit the artwork using SVG format –– which you can view even in a browser, directly; my home page is SVG embedded in HTML ––, including any fills, and only use HPGL to export the artwork from Inkscape to the plotter.
 
The following users thanked this post: Someone, hanakp


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf