AutoCAD Customization Guide Chapter 2 -- Linetypes and Hatch Patterns - Creating Hatch Patterns Developing a hatch pattern definition for AutoCAD requires some knowledge, practice, and patience, and also a text editor. You can add a pattern to the library file acad.pat or store it in a file by itself, in which case the file name must be the same as the pattern name. For instance, a pattern named PIT would reside in the file pit.pat. Regardless of where the definition is stored, it has the same format. It has a header line that looks like this: *pattern-name [, description] It also has one or more line descriptors of the following form. angle, x-origin, y-origin, delta-x, delta-y [, dash-1, dash-2, ...] AutoCAD ignores blank lines and text to the right of a semicolon. For example, a pattern called L45 that hatches with 45-degree lines separated by a spacing of 0.5 would be defined as follows: *L45,45 degree lines 45, 0,0, 0,0.5 This simple pattern specifies that a line is to be drawn at an angle of 45 degrees, that the first line of the family of hatch lines is to pass through the (0,0) drawing origin, and that the spacing between hatch lines of the family is to be 0.5 drawing units. L45 is the name of the pattern, and the description field is the optional description of the pattern displayed by the HATCH ? command. (If you omit the description, do not include a comma after the pattern name.) Each line in a pattern definition file can contain up to 80 characters. ---- AutoCAD Customization Guide Chapter 2 -- Linetypes and Hatch Patterns - Creating Hatch Patterns --The AutoCAD Pattern File --acad.pat The default hatch patterns used by AutoCAD are stored in the file acad.pat. You can add pattern definitions to this file or create your own files, as previously described. The Boundary Hatch and Hatch Pattern Palette dialog boxes display the names of all the hatch patterns defined in the file acad.pat. You can add new hatch patterns to the dialog boxes by adding the hatch definitions to the acad.pat file. Whenever a slide name in acad.slb matches a pattern name in acad.pat, the slide is also displayed by the dialog boxes. For more information see BHATCH in the Command Reference. ---- AutoCAD Customization Guide Chapter 2 -- Linetypes and Hatch Patterns - Creating Hatch Patterns --Patterns with Dashed Lines A pattern is made up of one or more pattern lines. (AutoCAD imposes no limit on the number of lines.) Each pattern line is considered the first member of a line family, created by applying the delta offsets in both directions to generate an infinite family of parallel lines. The delta-y value gives the spacing between members of the family (that is, it is measured perpendicular to the lines). Delta-x gives the displacement between members of the family in the direction of the line; it is meaningful only for dashed lines. (A line is considered to be of infinite length; a dash pattern is superimposed on the line.) The process of hatching consists of expanding each line in the pattern definition to its infinite family of parallel lines. All selected objects are checked for intersections with any of these lines; any intersections cause the hatch lines to be turned on and off as governed by the hatching style. If the hatch line is dashed, it is drawn with the dash pattern in those areas. Because each family of hatch lines is generated by parallel transport from an initial line with an absolute origin, the hatching of adjacent areas is guaranteed to align properly. ---- AutoCAD Customization Guide Chapter 2 -- Linetypes and Hatch Patterns - Creating Hatch Patterns --How Hatch Patterns Are Constructed To define dashed line patterns, you append dash-length items to the end of the line definition item. Each dash-length item specifies the length of a segment making up the line. If the length is positive, a pen-down segment will be drawn. If the length is negative, the segment is pen-up, and it won't be drawn. The pattern starts at the origin point with the first segment, and cycles through the segments in circular fashion. A dash length of 0 draws a dot. You can specify up to six dash lengths per pattern line. For example, modify a pattern for 45-degree lines to draw dashed lines with a dash length of 0.5 units and a spacing between dashes of 0.5 units. Such a pattern would be defined as follows. *DASH45,Dashed lines at 45 degrees 45, 0,0, 0,.5, .5,-.5 This is the same as the original 45-degree pattern, but you have added a dash specification to the end. The pen-down length is 0.5 units, and the pen-up length is 0.5, meeting the stated objectives. If you wanted to draw a 0.5-unit dash, a 0.25-unit space, a dot, and a 0.25-unit space before the next dash, the definition would be as follows: *DDOT45,Dash dot dash pattern: 45 degrees 45, 0,0, 0,.5, .5,-.25,0,-.25 Now consider the effect of delta-x specifications on dashed-line families. First, consider the following definition: *GOSTAK 0, 0,0, 0,.5, .5,-.5 This draws a family of lines separated by 0.5, with each line broken equally into dashes and spaces. Since delta-x is zero, the dashes in each family member line up. An area hatched with this pattern would look like this: - - - - - - - - - - - - - - - - - - - - - - - - - - - Now change the pattern to *SKEWED 0, 0,0, .5,.5, .5,-.5 It is the same, except that you have set delta-x to 0.5. This offsets each successive family member by 0.5 in the direction of the line (in this case, parallel to the X axis). Because the lines are infinite, the dash pattern slides down the specified amount. The hatched area would look like this: - - - - - - - - - - - - - - - - - - - - - - - - - - - So far, the patterns described here use origin points of (0,0); thus one member of the line family passes through the origin, with its dash pattern starting at that point. In composing more complex patterns, you need to carefully specify the starting point, offsets, and dash pattern of each line family to form the hatch pattern correctly. Consider the following. You want to draw a squared-off, inverted U pattern (one line up, one over, and one down). In the following figure, the pattern repeats every one unit, and each unit is 0.5 high and wide. This pattern would be defined as follows: *IUS,Inverted U's 90, 0,0, 0,1, .5,-.5 0, 0,.5, 0,1, .5,-.5 270, .5,.5, 0,1, .5,-.5 The first line (the up bar) is a simple dashed line with (0,0) origin. The second line (the top bar) should begin at the end of the up bar, so its origin is (0,.5). The third line (the down bar) must start at the end of the top bar--at (.5,.5) for the first instance of the pattern--so its origin is at this point. The third line of the pattern could be the following: 90, .5,0, 0,1, .5,-.5 or 270, .5,1, 0,1, -.5,.5 The dashed pattern starts at the origin points and continues in the vector direction given by the angle specification. Therefore, two dashed-line families that are opposed 180 degrees are not alike. Two solid-line families are alike. Consider the following pattern of six-pointed stars. This example can help you refine your skills at pattern definition. (Hint: 0.866 is the sine of 60 degrees.) The following is the AutoCAD definition of this pattern: *STARS,Star of David 0, 0,0, 0,.866, .5,-.5 60, 0,0, 0,.866, .5,-.5 120, .25,.433, 0,.866, .5,-.5