AutoCAD: How to Create a Custom Hatch Pattern with Text in it

This how I did it. It was a bit long but it helped me understand what to deal with when creating you own patterns.
Català - Castellano - Deutsch
On my last post, I analysed how the Hatch Pattern files work. How they define the patterns through straight lines and what is the syntax they use. I was not entirely satisfied with all I learned and wrote here so I decided to go from the theory to the practice and try to create my own hatch pattern file.
I decided to not attempt just a random pattern, but one that required certain precision. So I set the goal to create a pattern that would repeat the text CAD-Addict.com. Possible? yes it is.
The process started by creating the text. If you remembered what I wrote on the previous post, a pattern is created by straight lines with linetypes that we can decide that repeat themselves the way we decide to. So how would we do it to show a text on our hatch pattern just with some straight lines? We had to find a way to align the lines of the text on a way that they would repeat themselves in different directions. Let's see an image to understand this.

The text with the C circled in Red is the original one, the ones circled in Yellow are the ones I used to be sure the lines allign. See that this text has only lines at 0 degrees, 90 degrees, 45 degrees and 135 degrees. Alligning the o degree lines it is easy. The important part is to manage to allign the 45/135 degrees and do it in a way that the 90 degree ines also allign. In this case the fact that the tilted lines are 45/135 degrees makes it easy, if the there where other angles it would have been much more difficult. (The original text, created with the standard AutoCAD text style, had the lines on the upper part of the A at a different angle, but I modified that to make the pattern file more easy to create. See in the image below, how with the original text there was no easy way to find common lines for the A.

The process I followed once I had the text aligned is simple. First I started to set up the 0 degree lines (Remember to check the previous post for more details on the syntax of the Hatch PAttern files).Picking the lower left corner of the C as 0,0 point it was all a question of measuring distances. Something you need to know is that linetypes in hatch patterns can only use 6 elements from DASH SPACE or DOT. We define DASH with positive value, space with negative and point with a zero. See the hatch pattern definition of the horizontal lines and you will get a better glimpse of what I mean.

The text highlighted in yellow doesn't belong to the pattern definition, I added it for reference while building the pattern file. As you can see, although all the lower horizontal lines of the letters are aligned, I couldn´t define them in a single line definition because I would have exceeded the maximum of 6 elements for the line type definition.
Lets go back to how the pattern file works. The first number defines the angle of the line, the second and third (the second column) defines the start point coordinates of that line, the 4th and 5th number (3rd column) describe the delta-x and delta-y of the line. This point requires certain attention. Lets take for instance the horizontal lines. The delta-x and delta-y I had to use was -1.0607,1.0607. Lets see graphically what that means.

The last column might have no values at all (if the line is continuous), or up to 6 to define its linetype. For the lower horizontal lines for the letters C, D and d, the pattern file I created describes 0.1,-0.4475,0.1475,-0.7949,0.0508,-2.702 as linetype. THis means 0.1 of dash,0.4475 of space,0.1475of dash,0.7949 of space,0.0508 of dash,2.702 of space. Why is the last space so much bigger than the other ones? Because it describes the distance between the last dash and the first one on the next text. See the image below and compare the dimension values to the first 4 ones above.

The 6th value, on the 4th column, the one that is disproportionately bigger compared to the others, belongs to this dimension.

I after all this information you don't still feel like you could create your won pattern, I can only tell you that the best way is to try to create one. Suddenly all the abstract concepts you are reading will start making sense.
Just a couple of points I discovered while creating the pattern file. Be sure there is at least one blank line at the end of all the definitions, or AutoCAD won't accept the pattern. Also, once you have created the YOURPATTERN.pat file (or while creating it to test it) save it under the following where all the Custom Patterns are in AutoCAD. generally that folder is under C:\Documents and Settings\USERNAME\Application Data\Autodesk\AUTOCADVERSION\enu\Support\pats.
If you want to see or test the pattern definition I created., you can download it here. And below you can see a snapshot of the pattern generated by the file.

I know the pattern is not very useful for everyday life, but creating it was very useful to understand how to create a custom hatch pattern.


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...