Hewlett Packard Graphics Language 2


AskInga logo

Original Article Date:  June 7, 2002

Anthony Cox from Red Box Design shares this article with us. It was originally created as an internal document to address some specific plotting issues when dealing with HPGL/2 plotfiles and contains some terrific reference material. Thanks Anthony!!

Anthony Cox from Red Box Design shares this article with us. It is based on an internal document that's part of their CAD Manual and address some specific plotting issues when dealing with HPGL/2 plotfiles. It's chalk full of terrific reference material and Anthony is willing to share the HTML version complete with illustrations upon request. Please contact him directly via email if you'd like a copy. His email address can be found at the bottom of the page. Thanks Anthony!!



HPGL vs HPGL/2
HPGL was developed by Hewlett Packard to drive its family of pen plotters. Most commands are vector oriented - pick up the pen, put down the pen, move here, move there. Very few complex commands are part of HPGL since the original plotters did not include powerful CPUs.

HPGL/2 was developed as a successor to HPGL to support many more advanced features that could be off loaded to plotters with powerful CPU's and large amounts of memory. HPGL/2 also includes quite a lot of raster controls and commands since most modern plotters are actually raster devices. This includes embedded pen definitions - up to 256 since a raster device can never run out of pens..., fill patterns, screened vectors, clipping windows, data transformation and the like.

Why do we use it?
MicroStation allows us a great deal of flexibility on how the final print will appear by using an editable list of preferences found in a Plot Driver File. This file allows us to decide what happens to colours, line styles, pen weights and so forth.

Three main advantages of using HPGL2:

  1. They are totally independent of any CAD program.
  2. They are difficult to alter - although they can be edited.
  3. They have the print size embedded in the file - making it difficult to plot out at the incorrect size.


Before we can use this type of file we must understand the process in creating plotfiles.

Creating Plot Files:
Each time we press the Print button in MicroStation, and are using the correct plot driver file, we are sending HPGL2 information directly to the plotter.

The creation of a plotfile is the recording of the information that is sent to the plotter and consists of three parts:



Typically the file will have the same name as the design file with the suffix of PLT instead of DGN.

It is possible to look at this file in Notepad or WordPad, however larger plotfiles tend to crash Notepad. To create a plotfile we need to tell MicroStation to re-direct the output to a file rather than the plotting device. This is explained later. More often, you are likely to receive somebody else's plotfile, and so we need to understand how to send a plotfile to a printer/plotter.

Sending the Plotfile to a Printer/Plotter:
There are two way of sending the information to a plotter. The first way is to view the information using a program and then print it in the normal "Windows" fashion. Unfortunately, as soon as you do this, you negate all three of the advantages of using plotfiles.



The second way is to send the information directly to the plotter by using a simple DOS command. This would allow us to avoid the operating system entirely but does require you to know the name of the printer, the name of the plotfile and the exact location of both.

One of the most difficult things with this is determining the "Unique Naming Convention" path to the plotter. This is affected by how the plotter is linked to the computer holding the plotfile information.

To Determine the "Unique Naming Convention" (UNC) path to the Plotter:
To establish the "address" of the printer/plotter, we first need to understand how it is attached to your computer. There are three ways this can be done:



If the plotter is connected directly to the back of your computer with a single cable, then your plotter is connected to a Local Port. Convention dictates the you have two of these:LPT1 and LPT2. The operating system automatically allocates LPT1 to the first device it finds which is in most cases your plotter.

We can now define the UNC of the plotter in question as:

LPT1

To send a plot file using DOS you simply type the following:

Type plotfile.plt>LPT1

If LPT1 does not work, try LPT2.

If the plotter is attached to a Direct Jet Card, then the solution for determining the UNC is unknown.

If the plotter is attached to a remote computer, we need to know the name of that computer, and the name of the plotter. The name of the plotter can be determined from Windows by going to the Print dialog. In the following example, we are looking for the name of A0 roll fed Design Jet 488 Plotter.

Depending upon the Windows operating system you are running, navigate to the Printers dialog that lists your printers. This dialog will also tell you the name of the computer that the plotter is connected to. In our shop, we see that HPDJ488 is connected on REDBOX01. The next thing to find out is the share name of the plotter. On most Windows systems, you should be able to simply highlight the plotter in the dialog and go to File > Properties. Then select the Sharing tab and you'll should be able to see the share name. For us it will be HPDJ488CA. Note that the name of the plotter can be entirely different than its share name.

We can now define the UNC of the plotter in question as: \\REDBOX01\HPDJ488CA

Since it's possible to place spaces in share names, it's always a good idea to enclose everything in quotation markers such as this: "\\REDBOX01\HPDJ488CA".

(For additional information about share names and computer names with respect to your plotter, please refer to: / How to plot a file

To send a plot file using DOS you then type the following:

Type plotfile.plt>"\\REDBOX01\HPDJ488CA"

Using and typing in long filenames in DOS can be rather difficult, and it's often better to create a simple batch file to automate the printing process.

Create a Batch File to Automate the Printing Process:
First we must override the default Windows settings for viewing files, so depending upon which Windows Operating System you have, navigate to either the View Options or Folder Options dialog and ensure that the following are set:



Decide on a generic name for the batch file - we call ours A0_Plotter.bat and A1_Plotter.bat

Open either Notepad or Wordpad, create a new text file, and enter the following line (don't forget to subsutitue your *own* computor and plotter names): TYPE %1>"\\redbox01\HPDJ488CA"

Note, you can also use the DOS command "COPY" instead of "TYPE" as shown. Save your file as AO_Plotter.bat and place a shortcut to the file on your Desktop.

You now have a file that will allow you to "Drag and Drop" plotfiles. The only limitation is that you can only do one file at at time.

Changing the Shortcut Icon:
You will notice that the shortcut to your new file is a generic icon and it would be rather nice to change it to something of meaning. The HP logo is something most users are familiar with so we'll change the shortcut to use this highly recognized logo. Icon images are traditionally found in files with the extension of ICO and will be located somewhere on your HP Product Installation CD. You'll need to copy the ICO file containing the logo you want to the same location as your newly created batch file and rename it to something like HP.ICO.

To alter the icon of the shortcut on your desktop, just do a Right-click > Properties and select Change Icon. You'll probably get a message saying the btch file contains no icons, which isn't a problem. Just click the OK and then the Browse button. Navigate to your folder and select the icon file. Your shortcut now has the icon associated with HP Products.

"Send To" a Plotter:
One nice function of Windows is the right click Send To option and by adding a shortcut to the batch file it is possible to select a file and "Send To" the plotter by just doing a right-click!

Again, the following depends upon the version of Windows your running...but you need to get to navigate the to Send To folder for your Windows Profile. Once it's located, all you need to do is place a shortcut to the batch file in that folder. The shortcut will now be availalbe when you do a right-click on any file.

Plot Files from MicroStation:
As noted before, the way MicroStation translates the information from the screen to the plotter can be highly customised with the use of a plot driver file. Bentley has supplied a series of drivers for various plotters including HP plotters. This has led to some confusion since the majority of those are simply HPGL2 settings that can be applied to *any* HPGL2 device - including LaserJet 4MV printers.

Contents of a MicroStation HPGL2 Plotfile:
It's possible to examine a plotfile and obtain useful information from it - primarily the size of the plot. As noted earlier the plotfile has three parts:



The following informationn are the typical commands found in an HPGL2 plotfile. The commands are normally separated by a semicolon and for clarity each command has been isolated onto a single line. Note that the actual graphical information has also been removed.

%0BBP1
Enters the HP-GL/2 mode, BP=Begin Plot

"test.dgn"
File name

INPS33240,21328
Initialise the plotter and establish the plot size, in plotter resolution units, as 33240,21328.

QL100
Quality Level = 100 which is the best setting.

SC
Scale

NP64
Number of Pens = 64

TR0
Tranpareny mode where 0 is Off and 1 is On.

LA1,1,2,2,3,1.500000
Unknown

PW0.025000
Pen Width in plotter resolution units = 0.025 mm

PE
Unknown

PC0,255,255,255
Pen Colour 0 = RGB Values of 255,255,255

PC1,0,0,0 to PC63,200,0,0
Remaining pens

IW0,1072,33239,21327
Input Window - possibly used for margins.

PE
Actual graphical information

PUSP0
Unknown

PG
Advance full page

Determine the Page Size from a Plotfile:
The most useful information that can be determined from a plot file is the page size. If you multiply the INPS values by the PW you get the size of the output in millimetres. 33240x0.025=831mm, 22400x0,.025=560mm which is an A1 sheet in landscape mode allowing for 10mm margins on the long side and 17mm margins on the short side.

AskInga Article #104