Homebrew, open source, repurposed, hacked, software defined, open hardware

Friday, 8 September 2017

Importing HPGL plot data into pcb-rnd PCB layouts

HPGL support has now been added to pcb-rnd, allowing import of HPGL plot data exported from programs such as mechanical CAD packages and graphic design and page layout packages such as Inkscape.

HPGL, short for "Hewlett Packard Graphics Language", is a simple graphics language tailored to the needs of plotters, allowing multiple pens to be defined, along with paths, arcs, and pen up, and pen down commands.

The importer code will import an HPGL file into a PCB layout, allowing artwork to be added to copper layers, silkscreen layers, mask layers, or outline layers.

Importantly, the outline layer is used to define board shapes. If the board is to fit a selected enclosure, the geometry is commonly available in and manipulated with mechanical CAD software packages which can export HPGL.

Of particular note, pcb-rnd supports subtraction layer types, allowing artwork to be subtracted from soldermask, paste and silk layers to achieve more complicated effects.

Users keen to convert bitmaps to outlines can achieve this easily in Inkscape with the "convert bitmap to outline" function, followed by export in HPGL format.

The first step is to import the bitmap into Inkscape


The bitmap is then placed on the sheet:


The bitmap need to be selected with a mouse click:


Having done this, the bitmap can be converted to an outline:


The dialogue box even allows the bitmap to be inverted if required:


having traced the outline, the bitmap and the outline will be overlaid on the sheet



The bitmap can be deleted, leaving just the traced outline, at which point export to HPGL can be performed:
 


After exporting the paths to an HPGL file, the HPGL file can be imported into pcb-rnd


the HPGL data then appears in the paste buffer:


After clicking, the paste buffer contents appear on the active layer:


For those playing with Kicad's pcbnew layout editor, this code now provides a pathway for HPGL->Kicad PCB layout format, since pcb-rnd supports export to Kicad layout format.

For those exporting to a Kicad layout, this is as simple as a "Save As" in the File menu, and here is the exported layout in pcbnew: 


Multilayer combinations are obviously possible, which can then be combined into a single subcircuit if required:


In the above screenshot, subtraction layers have been added and can be seen in the layer list on the left.

Layers can be quickly and easily added to groups by either right clicking in the layer list on the left of the layout window. In addition, layers can also be added, along with manipulation of the layer stackup, in the preferences->layers dialogue window. This dynamic manipulation of the layer stackup is now possible thanks to the extensive layer refactoring previously undertaken in pcb-rnd.

The next packaged release of pcb-rnd will include the HPGL import code. For now, until then, it can be obtained from svn head and compiled.

The code that converts the HPGL data resides in a LGPL licensed C89 library called Libuhpgl. Libuhgpl is a small, portable library for parsing and generating HPGL data. It is suited to use in any software that can import or export 2d object models.

No comments:

Post a Comment