Skip to content
clnbtlrPublic

About

Python script for creating custom hatch patterns for AutoCAD

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

patWriter

patWriter is a Python script that converts any lines drawn in AutoCAD into a hatch pattern file (.pat) for use in AutoCAD.

Although AutoCAD includes a standard library of hatch patterns, custom hatches allow you to create and use your own patterns to suit your needs. The advantage of hatch patterns over AutoCAD's SuperHatch tool is that hatches support annotative scaling which automatically resizes the pattern based on the current viewport or annotation scale while SuperHatch does not.

The examples in this repository are designed for mapping applications in the legend style of Tailte Éireann (formerly Ordnance Survey Ireland).

patWriter hatch pattern

Usage

  1. In AutoCAD, draw one unit cell of the pattern you want to use as hatch pattern. Polylines, Arcs, Splines, etc. should be exploded and divided into individual line objects.
  2. Using AutoCAD's Data Extraction wizard, export information related to the unit cell line objects:
    1. The first time you extract data, you are prompted to save the data extraction settings in a data extraction (.dxex) file. This file can also be used again as a template to perform the same type of extraction in a different drawing.
    2. Select the line objects in the current drawing using the selection tool.
    3. On the next page, ensure only line objects are selected in the table.
    4. In the properties table, include Angle, End X, End Y, Length, Start X and Start Y from the Geometry category.
    5. Refine the data table if required.
    6. Output the data to an external .txt file.
    7. Create the file by clicking Finish.
  3. After downloading the patWriter.py script, run it using:
    python3 patWriter.py -f <path_to_txt_data_extraction> -b bbx bby -w <hatch_name>
    
    replacing <path_to_txt_data_extraction> to the location of the .txt file exported from AutoCAD's Data Extraction wizard in the previous step, bbx bby with bounding box length and width of the unit cell and <hatch_name> with the name for writing the .pat file.
  4. To make the hatch pattern available for use in AutoCAD, add its location as a custom folder to the application support files search paths in Options > Files > Support File Search Path > Add.

Examples

Name Pattern
Woodland Coniferous image
Woodland Deciduous image
Woodland Mixed image
Outcrop image
Marsh image
Bog image
Flatrock image
Sand image
Sand and Shingle image

Credits

This code is based on the pat_writer repository by Justin-Yeung which is mainly intended for Rhino 8.

About

Python script for creating custom hatch patterns for AutoCAD

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages