Updated for AutoCAD 2000!

13. Creating a Hatch Pattern, Part 2

by Ralph Grabowski

Last lesson, we were introduced to AutoCAD's hatch patterns and how they work. We created a simple pattern on-the-fly with the Hatch command. This lesson, we dig into the contents of the Acad.Pat file to get a better understanding of how a pattern is constructed.

1. Start a text editor (not a word processor), such as Windows NotePad.

2. Load the Acad.Pat file from the \Support subdirectory for your version of AutoCAD.

3. Take a look at the seemingly-incomprehensible series of numbers and punctuation contained by this file. I've reproduced the first dozen lines here; it's my job to make them comprehensible to you:

;; ;; Ver. 12.0 - AutoCAD Hatch Pattern File ;; 
*ANGLE, Angle steel 0, 0,0, 0,.275, .2,-.075 90, 0,0, 0,.275, .2,-.075 
*ANSI31, ANSI Iron, Brick, Stone masonry 45, 0,0, 0,.125 
*ANSI32, ANSI Steel 45, 0,0, 0,.375 45, .176776695,0, 0,.375

Comment and Header Lines

The semi-colon (;) indicates a comment line, such as ";; Ver. 12.0 - AutoCAD Hatch Pattern File". That lets you include notes to yourself that are ignored by AutoCAD.

The definition of a hatch pattern consists of two or more lines of text. The first line is called the "header," such as "*ANGLE, Angle steel"

The asterisk (*) is important because it signals to AutoCAD the start of a new hatch pattern definition.

Next comes the name for the hatch pattern, such as "ANGLE". The name must be unique in the file. If it isn't, AutoCAD uses the first pattern it finds by that name.

The comma following the name merely separates the name from the description. The comma is optional; it doesn't have to be there: a space works just as well.

The text following the pattern name is the description displayed by the Hatch ? command, such as "Angle Steel." This description is also optional but highly recommended. You are limited to a maximum of 80 characters for the name, comma, and the description. If you need more room for the description, use comment lines, such as:

; The hatch patterns that start with AR-xxxxx 
; come from AEC/Architectural. 
*AR-B816, 8x16 Block elevation stretcher bond

The Hatch Data

With the comment lines and the header line out of the way, let's get down to the nitty-gritty hatch pattern data and how it is coded. Lines 2 and following are the data, such as:

0, 0,0, 0,.275, .2,-.075 90, 0,0, 0,.275, .2,-.075

Every line of data uses the same format:

angle, x-origin, y-origin, x-offset, y-offset [, dash1, ...]

Angle: The angle that this line of hatch pattern data is displayed at. "0" means that the hatch line is drawn horizontally; "90" means the line is drawn vertically.

Comma (,) Separates the numbers.

X-origin: The first line of the hatch pattern passes through this x-coordinate.

Y-origin: The first line of the hatch pattern passes through this y-coordinate.

X-offset The distance between line segments; the gap distance. You only use this parameter to specify the offset for vertical or diagonal lines (To specify the distance between dashes, use the dash1 parameter.) In most hatch patterns, the x-offset has a value of 0.0; however, even though this parameter is rarely used, it is not optional.

Y-offset The vertical distance between repeating lines; this parameter is used by every hatch pattern.

Dash1 You use one or more of these dash1 parameters to define dashes in the hatch pattern line. The code is the same as for linetypes. A positive number, such as .25, is the length of the dash. A 0 draws a dot. A negative number, such as -.25, draws a gap. The dot drawn by the hatch pattern is actually a zero-length line. This creates a problem when it comes time to plot, since dots in a hatch pattern are not printed by some plotters, especially laser printers. Instead of code 0, you should use a very short line segment, such as 0.01.

When you are done editing a pattern or creating a new one, save the PAT file with the same name or a new name. Note that if you use a filename (other than Acad.Pat), the filename must match the pattern name, otherwise AutoCAD cannot find it. For example, you have created a new hatch pattern called "Earth" and you want it separate from the Acad.Pat file. The filename must be Earth.Pat. Even though Earth.Pat can contain other hatch pattern definitions (say, Forest, Meadow, and Lake), AutoCAD will never find them. The Forest pattern must be added to Acad.Pat or by itself in Forest.Pat.

Tips on Creating Pattern Codes

Some miscellaneous comments on hatch pattern coding:

Command: snapang 
New value for SNAPANG <0>: 20
Command: snap 
Snap spacing or ON/OFF/Aspect/Rotate/Style: rotate 
Base point <0,0>: 5,5 
Rotation angle <0>: 20
*Thick_Line, Closely spaced lines 0, 0,0, 0,.25 0, 0,.01, 0,.25 0, 0,.02, 0,.25

Angle
Dash length (sine)

    0

    0

30
0.433
45
0.707
60
0.866
90
1.0

*AR-SAND, Random dot pattern
;angle  x,-yorigin      x,y-offset      dash codes (dot, gap, dot, gap, dot, gap)
37.5,   0,0,            1.123,1.567,    0,      -1.52,   0,     -1.7,   0,      -1.625
7.5,    0,0,            2.123,2.567,    0,      -.82,   0,      -1.37,  0,      -.525
-32.5,  -1.23,0,        2.6234,1.678,   0,      -.5,    0,      -1.8,   0,      -2.35
-42.5,  -1.23,0,        1.6234,2.678,   0,      -.25,   0,      -1.18,  0,      -1.35

This lesson, we examined the numbers and punctuation that make up the code AutoCAD uses to create hatch patterns in our drawings. Next lesson, we look at how to add our custom-made hatch patterns to the BHatch dialog box.


Tailoring AutoCAD Part 12 | Part 13 | Part 14 is the next tutorial.

Comments on this tutorial series? Tell me about it.

Return to home page.

All contents copyright 1995-9 XYZ Publishing, Ltd. . All rights are reserved. No material may be reproduced electronically or in print without written permission from XYZ Publishing, PO Box 3053, Sumas WA, 98295-3053, unless otherwise noted.