HPGL language: SW to convert polygons to set of parallel lines? - Page 1
Forum section: electronics / general

author: hanakp
author_rank: Regular Contributor
timestamp: October 05, 2024, 07:32:15 pm
content: 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 foundPloView, but it seems it doesn't have such function.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 05, 2024, 10:33:57 pm
content: HPGL is still used with vinyl cutters, although fills aren't an issue there. I know free, open sourcehp2xxtool can do it (hp2xx-3.5.0a35, usinghp2xx -m hpgl -fout.pltin.plt), but its polygon fill routine is imperfect in certain corner cases.Note that free, open sourceInkscapecan read and save HPGL files, but as it is geared towards vinyl cutters, it doesn't do fills.

author: Someone
author_rank: Super Contributor
timestamp: October 05, 2024, 11:38:41 pm
content: 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

author: hanakp
author_rank: Regular Contributor
timestamp: October 15, 2024, 11:03:26 pm
content: 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.Quote from: Nominal Animal on October 05, 2024, 10:33:57 pmI 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?

author: hanakp
author_rank: Regular Contributor
timestamp: October 16, 2024, 10:03:44 pm
content: Sohp2xx 3.5.0isn'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 fromCERN HPGL Viewerthat 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 commandhp2xx -t -m hpgl -p 33333333 -f out.plt onepoly.pltI also checked out Inkscape, but it looks... daunting.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 21, 2024, 10:14:29 am
content: 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.Chiplotle3library. 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 anInkscape extensionin Python for customized HPGL export.However, if you use SVG and Inkscape for processing your artwork, you can use existingextensions, for example built-inGcodeTools>Area..., or if you install Eggbot extensions, itsHatch 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 thenPath>FractureorBreak 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 pageis SVG embedded in HTML ––, including any fills, and only use HPGL to export the artwork from Inkscape to the plotter.