From Cheap Tricks, June 96 Issue

Published By:
Shu Associates, Inc.
120 Trenton St., Melrose, MA 02176-3714
(617)662-0020 (FAX Same)

Custom Hatching

by Evan H. Shu, AIA

This month, we thought we'd take another run at how you can design your own custom hatching for DataCAD. In February '93, we printed an excellent article by Christopher Glass. Rather than just refer you to it or re-print, we decided to approach the subject with another example to help you understand how it works. First a word of warning, writing your own custom hatch patterns is not for everyone. It requires time, patience, discipline and will severely stretch your memory cells as you try to recall your high school geometry lessons. Nevertheless, once completed, it will give you a great deal of satisfaction to have written your first custom hatch.

All the hatch patterns are kept in a simple ASCII (plain text) file called DCAD.PAT (DCADWIN.PAT for DataCAD 8 for Windows and above) found in the SUP directory under your main DataCAD heading. If you pull this file up in your word processor, you will see each individual hatch pattern starts with a asterisk and the hatch name, then a series of lines which are made up of numbers and commas. For you astute computer heads out there, you might recognize this file as a comma delimited database formatted file. Basically that means that each line is one record or instruction and each number separated by a comma represents a field or category of that record/instruction. If you understand what each of these numbers represents, you are on your way to writing your own custom hatch pattern.

0, 0, 45, 0, 0, 0, 1

The above hatch description for "ansi31", which you can think of as a simple angled hatch of solid lines is described in one terse line. The first number stands for line weight, which is always "0" in DataCAD because DataCAD controls line weight separately. The second number is line color, which again is always "0" in DataCAD. (We keep saying "in DataCAD" because AutoCAD also utilizes the exact same hatch file format, but they do utilize those two numbers.) The third number, as you might guess, stands for "Angle", in this case forty-five degrees. The fourth and fifth numbers stand for the distance from the origin along the X-axis and Y-axis respectively. The sixth number stands for offset distance along the X-axis to the repeat (for solid lines, this number will always be zero.) The seventh number stands for the offset distance along the Y-axis, which is, more often than not, your basic spacing distance. The final number(s) describe the line to be repeated itself. This description can add have up to six more numbers to the line, but the values must alternate between positive and negative. A positive number means "pen down" and negative number means "pen up", so you can have up to 3 different line segments before the pattern repeats. The basic unit of distance here is 1 unit = 1/32nd of an inch. Scale can be adjusted within DataCAD, so make your life as easy as possible when you figure these out. (If you want to describe your distances in full-scale dimensions, then by using 1 as your hatch scale in DataCAD, the hatch will come out at full-scale.) In the above example, we just have one solid line, repeating, so a single "1" suffices to describe it all.

As you can surmise, this format does not allow for curved arcs in your hatch description. But if you work extremely hard at it, you can simulate a curve via segmented lines.

Let's step up our custom hatch study by moving up one level in complexity. We borrowed this tile example from Hatch Manager (Cheap Tricks Ware M-9) by D/PA but we have come up with our own hatch description. As you will find, any singular hatch pattern can be described in an infinite number of different ways. [Picture a standard square tile pattern but with diamonds at all the intersections.]

When you decide to design a custom hatch, you best bet is to first draw your desired pattern on a sheet of grid paper, so that you can figure out your units more easily. You need to determine your repeating horizontal lines, your repeating vertical lines, and your repeating angled lines. You also need to pick an origin point that makes your life as easy as possible -- namely a point where a lot of your lines intersect, so that they alll can use 0,0 as their origin point.

One way to envision the way the computer works with these hatch descriptions is to imagine that you are standing at the origin point with a "line bazooka" (which shoots in both directions at once and does a spread pattern as well) in your hands. You load your line gun with the first line description, turn to the proper angle and fire it. Using your "Dy" spacing stipulation as its "spread" pattern, it repeats the line at the designated offset spacing until it hits your boundary. You then load your line gun with the second description, turn to the proper angle and fire again. Sequentially, you take up each line one by one. Watch DataCAD hatch a complicated pattern and you will see this "line gun" in operation.

Our tile pattern has six repeating lines: one set of horizontals, one set of verticals and four sets of diagonal repeats. You may ask why four sets and not two, since there are only two different angles, 45 and 135. It's because if you look at the 45 degree lines, there are two different spacings. Hatch lines can only have one spacing unit, so you have to do them separately. We pick the origin where three lines intersect, one horizontal and two diagonal lines.

The horizontal lines (H1) are fairly easy. They are spaced 5 units apart vertically and are made up of one solid dash 3 units long followed by a 2 unit space. Hence there line is described:

0, 0, 0, 0, 0, 0, 5, 3, -2

Before we begin with the other lines, you have to know that the Dx and Dy spacing units are always figured as if any angled line has been turned back to the "0" angle. In our metaphor, the line gun is loaded first with the ammunication and spread pattern, then finally turned to the proper angle.

The vertical lines (V1) differ from the horizontals only in distance from the origin and the angle:

0, 0, 90, -1, 1, 0, 5, 3, -2.

The first set of Diagonals (D1) are angled at 45, start at the origin, and can be described as starting with a space 5.656 units long followed by a solid dash 1.414 units long. (We could have reversed the line description if we used 225 as our angle instead.) The tricky part comes in figuring the Dx and Dy. If you imagine rotating these diagonals back to zero, you will see that there is a staggered offset to the repeat. The stagger is equal to 3.536 units in the X direction and 3.536 units in the Y direction. Thus the description is written as follows: 0, 0, 45, 0, 0, 3.536, 3.536, -5.656, 1.414. Study this particular line carefully. If you can conceptualize what is happening here, you've got hatch patterns pretty much licked.

The other set of Diagonals (D2, D3, D4) are variations of D1. D2 is exactly like D1 exact offset from the origin -1 & 1. D3 is angled at 135 degrees at starts with the solid dash of 1.414 then followed by the space of 5.656. D4 is exactly like D3 except offset from the origin point -1, -1. So all three would be written as follows:
0, 0, 45, -1, 1, 3.536, 3.536, -5.656, 1.414
0, 0, 135, 0, 0, 3.536, 3.536, 1.414, -5.656
0, 0, 135, -1, -1, 3.536, 3.536, 1.414, -5.656

You put in all together and whaddaya-got?
*New Tile
0, 0, 0, 0, 0, 0, 5, 3, -2
0, 0, 90, -1, 1, 0, 5, 3, -2
0, 0, 45, 0, 0, 3.536, 3.536, -5.656, 1.414
0, 0, 45, -1, 1, 3.536, 3.536, -5.656, 1.414
0, 0, 135, 0, 0, 3.536, 3.536, 1.414, -5.656
0, 0, 135, -1, -1, 3.536, 3.536, 1.414, -5.656

This description can be inserted into your DCAD.PAT (or DCADWIN.PAT for DataCAD 8 for Windows and above) file in any order, and the hatches will be listed in the menu in the order the occur in the file. The name of your hatch can be anything you want but it can't exceed 8 characters.

The shell out feature of DataCAD (Ctrl-F12, then type "Exit" at the DOS prompt to return to DataCAD) makes writing custom hatches much easier. You can write your hatch into the DCAD.PAT file using the MS-DOS "EDIT" command, then shell back into DataCAD and test the hatch. If you've made a mistake, you shell back out and try to correct it with EDIT again, then shell back into DataCAD to test your change. Once you get the hang of it, it can actually be "fun".

We would be very remiss if we didn't tell you more about "Hatch Manager" (Cheap Tricks Ware M-9) by John Fornaro and Design/Program Associates. People buy it thinking that they can just draw their intended hatch and have the macro scan the pattern and automatically create the pattern. Well, no, it won't quite do that. But if you understand how a hatch pattern is created, it will take you line by line through the creation of a pattern and measure your line lengths and angles for you, so at least you don't have to worry about your geometry lessons as much. But you do need to understand the principles outlined above to make it work effectively for you. The other great feature of Hatch Manager is that it gives you control of the first two parameters of line width and line color. You can use it to actually design hatches that have a multiplicity of line weights and line colors.

We encourage you to design your own custom hatch pattern -- at least once. That way at least, you will realize what a great buy those various Cheap Tricks Ware custom hatch patterns are at only $5 or $10 bucks! Happy Hatching.

Reprints by permission only by Shu Associates, Copyright 1996
Note: (Typo corrections made and updated references to DataCAD 8 made on August 4, 1999)

To go back to the Reprints Page

How to Subscribe

Shu Associates Inc.
120 Trenton St.
Melrose, MA 02176-3714
(617)662-0020 Tel & Fax

You can E-mail us by clicking here:

Copyright © 1997-2000, Shu Associates Inc.