AutoCAD® hatch patterns

It's very easy to create your own hatch patterns. Hatch patterns are defined in .PAT-files, usually named ACAD.PAT and ACADISO.PAT.
A definition looks like this:

*PATTERN_NAME[, DESCRIPTION]
line1
line2
.
.


In common, blanks written in hatch pattern definition are not necessary for drawing the hatch patterns correctly! This is important when creating complex hatch patterns or line type definitions, because one line in the hatch pattern definition file (excluding carriage return and line feed) may not be longer than 80 characters! In the sample code they are only used for making the code easy to read.
A hatch pattern definition may use more than one line for line type definitions. Each line consists of:

angle, x-origin, y-origin, delta-x, delta-y, line, blank[, line, blank, ...]

Let's see how to do it looking on an example hatch pattern that will show big and small squares. Firstly, give your hatch pattern a name an a description. Secondly, we'll add the first line of the line type descriptions. The base point of the definition is the left bottom corner. For using angles, 0° is horizontal from left to right.


Positive angles are counter clockwise!

*SQUARES, big and small squares
0, 0,0, 0,1, 1,-1


So the first line is dashed horizontal (left to right) and start at the base point [0,0]. The line has no delta in x-direction and is repeating every 1 drawing unit (DU). So delta-y is 1. The line type definiton works like when defining your own AutoCAD® line types:


Positive values are lines,
negative values are spaces,
lines using length 0 are used for drawing dots!

So the line type definition 1,-1 means 1 DU line, 1 DU blank, repeating continuously.


Part 1 of the example hatch pattern:
Step 1 of hatch pattern definition





As you can see near by, the dashed line starts in [0,0].
Also the line is repeating in y-direction.

Step 1   (1.272 bytes)

The next line type definition draws the vertical dashed line:
90, 0,0, 0,1, 1,-1


Part 2.1 of the example hatch pattern:
Step 1 an 2 of hatch pattern definition


It's the same line type as used in Step 1,
but rotated 90 degrees counter clockwise.

Let's have a look at the second definition line:

90 ... the line is vertical upwards

0,0 ... the line starts in the same point as the first dashed line
(the first step is greyed out!)

Step 1 to 2.1   (2.327 bytes)

Part 2.2 of the example hatch pattern:
Step 1 an 2 of hatch pattern definition



For the rest of the line definition you have to
rotate the coodinate system:

0,1 ... means that the line is repeating in x-direction,
not in y-direction

1,-1 ... 1 DU line, 1 DU space (indicated by the minus)

Step 1 to 2.2   (2.317 bytes)

Now the big ones work. Let's start with the small squares:
0, 1.25,1.25, 0,2, .5,-1.5


Part 3.1 of the example hatch pattern:
Step 1 to 3 of hatch pattern definition



Let's see:

0 ... the line is horizontal from left to right

1.25,1.25 ... the line starts 1.25 DUs left from the origin
        and 1.25 DUs above the origin

Step 1 to 3.1   (2.385 bytes)

Part 3.2 of the example hatch pattern:
Step 1 to 3 of hatch pattern definition





0,2 ... the line is repeating in y-direction, every 2 drawing units

.5,-1.5 ... so the line type is half an DU line, and 1.5 DUs blank!

Step 1 to 3.2   (2.390 bytes)

We're still missing the second horizontal line:
0, 1.25,1.75, 0,2, .5,-1.5


Part 4.1 of the example hatch pattern:
Step 1 to 4 of hatch pattern definition





The only difference between Part 3 and Part 4 ist the y-origin,
that is 1.75 DUs and not 1.25 DUs!

Step 1 to 4.1   (2.418 bytes)

Part 4.2 of the example hatch pattern:
Step 1 to 4 of hatch pattern definition






... already said ...

Step 1 to 4.2   (2.436 bytes)

The first vertical line of the small squares is done this way:
90, 1.25,1.25, 0,2, .5,-1.5


Part 5.1 of the example hatch pattern:
Step 1 to 5 of hatch pattern definition






... It's very easy to do ...

Step 1 to 5.1   (2.683 bytes)

Part 5.2 of the example hatch pattern:
Step 1 to 5 of hatch pattern definition






... described above ...

Step 1 to 5.2   (2.608 bytes)

Finally draw the missing vertical line:
90, 1.75,1.25, 0,2, .5,-1.5


Part 6.1 of the example hatch pattern:
Step 1 to 6 of hatch pattern definition






... no more to say ...

Step 1 to 6.1   (2.895 bytes)

Part 6.2 of the example hatch pattern:
Step 1 to 6 of hatch pattern definition






... finished! ...

Step 1 to 6.2   (2.850 bytes)

As conclusion you can see the whole finished hatch pattern definition here! only insert it to your acad.pat-file, restart AutoCAD®, if running, and have a try!
*SQUARES, big and small squares
0, 0,0, 0,1, 1,-1
90, 0,0, 0,1, 1,-1
0, 1.25,1.25, 0,2, .5,-1.5
0, 1.25,1.75, 0,2, .5,-1.5
90, 1.25,1.25, 0,2, .5,-1.5
90, 1.75,1.25, 0,2, .5,-1.5


last update: 2009-12-30 - 19:41:15.
copyright © by Klaus Burgstaller 2009