HPGL/2 Converter Add-on¶
New in version 1.1.
hpgl2 add-on provides tools to process and convert HPGL/2 plot files.
What are HPGL/2 Plot Files?¶
The Hewlett-Packard Graphics Language (HPGL) is a vector graphics language originally developed by Hewlett-Packard in the 1970s. HPGL is widely used for controlling pen plotters and other output devices, and it has become a de facto standard for communicating between computers and output devices in the field of computer-aided design (CAD) and drafting.
HPGL is a command-driven language that consists of a series of commands that control the movement of the plotter pen, the selection of pens and other output parameters, and the drawing of geometric shapes such as lines, arcs, circles, and text. The language is interpreted by the plotter or other output device and translated into physical pen movements on the drawing surface.
HPGL has evolved over the years, and various extensions have been added to support more complex graphics operations and to improve compatibility with other graphics languages. Despite the development of newer graphics languages and file formats, HPGL remains a widely used format for vector-based graphics, particularly in the engineering and architectural fields.
The Goal of This Add-on¶
An HPGL/2 plot file contains all of the data generated by a CAD application that has been sent to a plotter to print an engineering drawing. In the past, the only way to access this data was to view it on a plotter or an specialized application, which could be expensive and impractical for many people. However, this module provides functions and classes to convert HPGL/2 plot files into modern vector graphic formats such as PDF and SVG and of course DXF, allowing the data to be viewed and processed using a wide range of software tools.
The Python module PyMuPDF is required for the PDF export: https://pypi.org/project/PyMuPDF/
Plotter class in the
hpgl2 add-on supports only the most commonly
used commands of HPGL/2. This is because many CAD applications use only a small subset
of HPGL/2 to create their output, typically consisting of polylines and filled polygons.
For more information on the supported commands, please refer to the documentation for
To use the HPGL2 add-on, the entry point is the
This module contains the public interface of the add-on and should be imported in the
from ezdxf.addons.hpgl2 import api as hpgl2
with open("hpgl2.plt", "rb") as fp:
data = fp.read()
doc = hpgl2.to_dxf(data, color_mode=hpgl2.ColorMode.ACI)
High Level Functions¶
- class ezdxf.addons.hpgl2.api.ColorMode¶
The color mode controls how color values are assigned to DXF entities
The Low Level Functions and Classes¶
Some plot files that contain pure HPGL/2 code do not contain the escape sequence
“Enter HPGL/2 mode”, without this sequence the HPGL/2 parser cannot recognize the
beginning of the HPGL/2 code. Add the
ENTER_HPGL2_MODE sequence in front of the
bytes stream to switch on the HPGL/2 manually, regardless of whether the file is an
HPGL/2 plot file or not, so be careful:
commands = hpgl2_commands(hpgl2.ENTER_HPGL2_MODE + data)
- class ezdxf.addons.hpgl2.properties.Properties¶
Consolidated display properties.
pen index as int
pen color as
pen width in millimeters (float)
fill hatch line angle in degrees
fill hatch line distance in plotter units
fill shading density in percent from 0 to 100.
- class ezdxf.addons.hpgl2.properties.FillType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Fill type enumeration.