By Dennis Collin
A common question I receive when training AutoCAD at various levels is, how easy it is to create complex custom hatch patterns? i.e. not just ones with parallel or crosshatch lines but ones with more bespoke arrangements. The answer is, the process is a little clunky. We must plan out a series of lines and points on paper or in our head, and type it out into a text file, save it with a PAT extension and then add it to our drawing or template file.
I usually see the questioner switch off at this point and mentally write off the custom hatch issue as not being possible, but hang in there, we have an easy solution!
For many years AutoCAD (and now AutoCAD LT 2024) can achieve tasks via its API. AutoLISP, despite being an older environment, can perform many popular tasks. This includes tedious tasks like creating custom hatch patterns.
The Cadalyst website has for many years been a repository of custom lisp routines provided by users which are available to download to use or to learn from.
I have provided a list of some useful Lisp resources previously here:
One such routine, Hatchmaker.lsp, once loaded using AutoCAD’s Appload function, provides two new commands DRAWHATCH and SAVEHATCH. In a nutshell it lets users draw a bespoke hatch using simple entities.
The Drawhatch command defines a boundary area, measuring 1 unit by 1 unit to provide the user a framework to define a custom hatch pattern with line and point entities. The constraints mean elements must be drawn within a 0,0 to 1,1 limit and lie on a 0.01-unit grid. If not, the elements will either be ignored or result in a hatch error creation message.
Once complete, the Savehatch command will ask the user to select the entities for the hatch, ask for a brief description and then ask for the name and location of the hatch pattern file to save to.
The routine also loads the new custom hatch pattern into the current AutoCAD drawing for testing. Unlike the Superhatch express tool that fakes a hatch pattern with a block, this is genuine hatch entity that can be trimmed, edited and queried for areas etc.
Of course, the hatch pattern can be defined manually using pen and paper and transfer the information to a text file. Simply create a text file in Notepad or similar and add your vectors and gaps in the following format!
*Cadline Custom Hatch,Cadline Custom Hatch
90,0.43284271,0.29284271,0,1,0.14142136,-0.85857864
0,0.29142136,0.43426407,0,1,0.14142136,-0.85857864
45,0.85710678,0.85852814,0.70710678,0.70710678,0.1,-1.31421356
45,0.7863961,0.92923882,0.70710678,0.70710678,0.1,-1.31421356
45,0.92781746,0.78781746,0.70710678,0.70710678,0.1,-1.31421356
315,0.7863961,0.92923882,0.70710678,0.70710678,0.2,-1.21421356
341.565051,0.64497475,0.78781746,0.9486833,0.31622777,0.2236068,-2.93867086
315,0.71568542,0.85852814,0.70710678,0.70710678,0.2,-1.21421356
135,0.7863961,0.6463961,0.70710678,0.70710678,0.2,-1.21421356
135,0.71568542,0.57568542,0.70710678,0.70710678,0.2,-1.21421356
45,0.57426407,0.43426407,0.70710678,0.70710678,0.1,-1.31421356
135,0.57426407,0.43426407,0.70710678,0.70710678,0.2,-1.21421356
315,0.29142136,0.43426407,0.70710678,0.70710678,0.2,-1.21421356
45,0.22071068,0.22213203,0.70710678,0.70710678,0.1,-1.31421356
315,0.22071068,0.36355339,0.70710678,0.70710678,0.2,-1.21421356
45,0.15,0.29284271,0.70710678,0.70710678,0.1,-1.31421356
315,0.15,0.29284271,0.70710678,0.70710678,0.2,-1.21421356
45,0.15,0.01,0.70710678,0.70710678,0.1,-1.31421356
315,0.00857864,0.15142136,0.70710678,0.70710678,0.2,-1.21421356
225,0.07928932,0.22213203,0.70710678,0.70710678,0.1,-1.31421356
Save this file as Cadline_hatch.pat or similar and load the new pattern into your CAD drawing file.
For more information on the formatting of AutoCAD’s PAT file go here:
It discusses formatting options to create a brick pattern with a mortar joint, set to UK sizes.
Comentários (0 comentários)