Hewlett-Packard Graphics Language

from Wikipedia, the free encyclopedia

The Hewlett Packard Graphics Language ( HP-GL ; German Hewlett-Packard graphics language ) is a page description language developed by Hewlett-Packard for controlling pen plotters . It was introduced in 1977 together with the HP-8972 plotter. Other plotter manufacturers have taken over HP-GL to control their own plotters.

Language structure

HP-GL is a simply structured language. The commands consist of two capital letters ( mnemonics ) followed by one or more arguments. The data are transmitted in "plain text" ( ASCII ).

Examples of HP-GL commands
command meaning
PA Position absolute (move pen to absolute coordinates)
PR Position relative (move pen by number of units)
PD Pen down
PU Pen up
SP Select pen

The coordinate system is based on the smallest unit supported by an HP plotter at the time and was set to 25  µm (40 units per millimeter or 1016 units per inch). HP-GL also contains commands ( LB ) for the output of simple ASCII texts.

Inkjet and laser plotters

HP-GL is also used to control inkjet and laser plotters. These plotters first build up the image in memory (one speaks of rasterization) and then output it on paper. These plotters work with “virtual pens”, which means there is a table in which a line width and, if necessary, a color is assigned to each pen number. This table can be permanently saved in the plotter (hardly used today) or sent with the HP-GL data (from HP-GL / 2 or with manufacturer-specific headers).

HP-GL / 2

HP-GL / 2 is a further development of the language HP-GL. An important innovation is the possibility of defining line widths (and other line attributes) as well as generating binary and thus space-saving encoded commands (e.g. PE = Polyline Encoding). Since HP-GL was developed for pen plotters, there were no commands to define the line widths because these were determined by the pens. The user had to equip the pen carousel according to his wishes. When the first inkjet plotters appeared, the user had to enter a pen table on the plotter instead. With HP-GL / 2, this uncomfortable and error-prone step became superfluous.

Examples of HP-GL / 2 commands
command meaning
NPx Number of Pens; x = 1..256
PCx, r, g, b Pen Color (set the color of pen x); x = pen, r = red, g = green, b = blue, each 0..255
PWw, x Pen Width (set the line width of pen x); w = line width in mm with decimal point, x = pen

Commands (mnemonics) in HP-GL / 2 can be written in upper or lower case. A command has no, one or more (optional) parameters. Separators for parameters can be: comma, space, + or - (for numbers). Commands are ended with: semicolon, the next command or space character. Commas and the next command or semicolon are recommended.

HP-GL and HP-GL / 2 as data exchange format

Although not designed for this, HP-GL evolved into the data exchange format for vector data of graphics because of its simplicity . Many CAD programs support export in HP-GL format. Another common way of generating HP-GL data is "printing to a file" with an appropriate printer driver. This is problematic because the language is expanded again and again with the appearance of new plotter models and this can lead to compatibility problems. Another problem is the manufacturer-specific headers that are sent before the actual HP-GL data in order to control certain plotter properties - for example the Printer Job Language from Hewlett-Packard or the Remote Control Format from Océ .

To avoid compatibility problems, the following applies (freely adapted from Jonathan Postel ): “Be liberal in what you accept, be conservative in what you send”. It can be assumed that the HP-750C plotter's instruction set is generally understood. In addition, the system-related accuracy of a "print" in this simple transmission format , which is very limited in terms of software, must be observed compared to the DXF file format.

HP-GL is also used to control engraving machines.

Sample csh script for printing labels

#!/bin/csh

set echo_style=both

set NAM='Johannes Herzogenrath\r'
set STR='Am Steinkamp 34b\r'
set ORT='32643  Leidenheim\r'
set TEL='Tel (05727) 7848571\r'
set TEXTA TEXTB
set OFILE=ETI_OUT
                                  # Etik. 48.5 x 25.4 (40=10x4)
echo "\e%-12345X\eE\e%1BinNP4;" >! $OFILE
echo "pc1,65,105,225pc2,250,240,230pc3,70,130,180;" >> $OFILE
echo "sc0,4,0,4,2;" >> $OFILE     # cp437=341,iso8859-1=14,-15=302,univers=52
echo "sd1,302,2,1,4,10,5,0,6,0,7,52ssDT|,1sp1wu0pw.1,1lo5ft1;" >> $OFILE
set STARTX=73 STARTY=107 ETIVER=10 ETIHOR=4
echo "PUpa$STARTX,$STARTY;" >> $OFILE
#   Relativbewegung Rechteckgroesse
set RXA=485 RYA=254 RXB=436 RYB=218
set VER=0 HOR=0 NUM=0 LBX=0 LBY=( 45 49 40 40 )
set TEXTA="$LBY[1];sp3sd4,8.25lb$TEL|;sp1pr0,$LBY[2];sd4,10.5lb$ORT|;"
set TEXTB="pr0,$LBY[3];lb$STR|;pr0,$LBY[4];lb$NAM|;"

while ( $VER < $ETIVER )
   @ NUM = ( $RXA * ( 1 - $ETIHOR ) )
   if ( $VER > 0 ) then
     echo "pr$NUM,$RYA;" >> $OFILE
   endif
   @ HOR = 0
   while ( $HOR < $ETIHOR )
      if ( $HOR > 0 ) then
        echo "pr$RXA,0;" >> $OFILE             # Rechteck-Position rel.
      endif
     #echo "sp2er$RXB,$RYB;sp1;" >> $OFILE     # Zeichne Rechteck rel.
      echo "sp2rr$RXB,$RYB;sp1;" >> $OFILE     # Fülle Rechteck rel.
      @ LBX = ( $RXB / 2 )
      echo "pr$LBX,$TEXTA$TEXTB" >> $OFILE
      @ LBX = - $LBX
      @ NUM = - ( $LBY[1] + $LBY[2] + $LBY[3] + $LBY[4] )
      echo "pr$LBX,$NUM;" >> $OFILE
      @ HOR++
   end
   @ VER++
end

echo "\e%0A\eE\e%-12345X" >> $OFILE
cat $OFILE > $DRUCKER
exit (0)

The script prints a sheet of A4 labels with 4 × 10 labels. The comments in the script (#comment) and the variable names ($ name) allow orientation. The "character strings" (red) contain HP-GL / 2 code and variable content. A rectangular area with the color linen and four lines of centered text in shades of blue with different character sizes are printed on a label . The rectangular area is smaller than a label. The drawing of a rectangular frame is commented out. The sequences \rand \emust be observed. They represent the non-printable characters CarriageReturn and ESCape . These sequences are echo_style=bothtaken into account by the (t) csh. The given text is a fantasy text.

See also

  • ShareCAD , free online service for viewing HP-GL / PLT

Web links

  • HP-GL Introduction (PDF; 111 kB; English; archive link to the Wayback Machine (Archive.org), original link no longer available).
  • HP-GL / 2 (PDF; 3.7 MiB) in the PCL5 manual (English)
  • HP-GL / 2 (PDF; 2.4 MiB) in the PCL5 Color Manual (English)