SECTION 1
Historical Context & Motivation
Long before computer-aided design entered the picture, engineers and architects relied on hand-drawn cross-hatching to indicate material types, sectional cuts, and filled regions on technical drawings. The act of drawing evenly spaced diagonal lines inside a closed boundary was tedious and error-prone, consuming hours of drafter time on a single sheet. When AutoCAD introduced its first hatching command in the mid-1980s, it automated this repetitive task, but the early implementation was rudimentary — it could fill a simple closed polyline, yet it struggled when interior objects (holes, nested boundaries) existed inside the hatch area. These interior objects are referred to as islands in CAD terminology, and the challenge of correctly detecting and handling them drove decades of algorithmic refinement within AutoCAD's hatch engine.
1984 • AutoCAD R2 — First Hatch Command
1997 • AutoCAD R14 — BHATCH & Boundary Detection
2004 • AutoCAD 2005 — Associative Hatching
2011 • AutoCAD 2012 — Ribbon-Based Hatch Creation
2020 • AutoCAD 2021 — Performance & Tolerance Enhancements
The central problem that hatching with islands addresses is fundamentally geometric: given a potentially complex, nested set of closed boundaries, how should the hatch engine decide which regions to fill and which to leave empty? This question maps neatly to concepts from computational geometry — point-in-polygon tests, flood-fill algorithms, and even-odd rule parity — making it an excellent case study for computer science students working at the intersection of algorithms and practical design software.
SECTION 2
Core Principles & Definitions
Before diving into implementation details, it is essential to establish the foundational vocabulary and principles governing AutoCAD's hatch system. The hatch engine operates on the interplay between boundary detection, island detection styles, and associativity. Understanding these three pillars is prerequisite to producing correct and maintainable hatch annotations in any technical drawing.
Hatch Boundary
Islands
Island Detection Styles
Associative vs. Non-Associative
Gap Tolerance
KEY TAKEAWAY
SECTION 3
Visual Explanation — Island Detection Modes
The following diagram illustrates the three island detection styles applied to the same nested boundary configuration. In each case, a large rectangle serves as the outer boundary, a medium circle is the first-level island, and a small square is the second-level sub-island (an island within the island). The hatched regions (shown with diagonal lines) differ dramatically between the three modes, demonstrating how a single geometric configuration produces three distinct visual results.
Observe how the Normal detection style mirrors the even-odd fill rule familiar from computer graphics: a region at even nesting depth (0, 2, 4…) is filled, while a region at odd nesting depth (1, 3, 5…) is skipped. This is the default mode and the most commonly used in architectural and mechanical sections. The Outer style is particularly useful when you want to highlight the material of an outer wall without visually cluttering interior components, such as when showing a cross-section of a pipe with internal baffles. The Ignore style treats the outer boundary as the sole constraint and floods everything inside, which can be useful for schematic or diagrammatic representations where material fills should be uniform.
SECTION 4
How It Works — Boundary Detection & Associativity Engine
Boundary Detection Algorithm
When you invoke the HATCH command and specify an internal pick point, AutoCAD performs a ray-casting boundary search. The engine casts rays from the pick point in multiple directions, identifying the nearest intersecting geometry on each ray. These intersection points collectively define a candidate boundary loop. The algorithm then validates that the loop is closed and non-self-intersecting before accepting it as the hatch boundary. This is conceptually similar to a point-in-polygon test run in reverse: rather than testing whether a point is inside a known polygon, the algorithm discovers the polygon that contains the point.
Once the outer boundary is established, the engine scans for all closed loops entirely contained within it. These are the islands, and they are sorted by their nesting depth — a metric computed by counting how many boundary loops enclose each sub-loop. The nesting depth directly determines which regions are filled under each island detection style.
NESTING DEPTH PARITY RULE (NORMAL MODE)
Where depth is the number of closed boundary loops that enclose the region. The outermost region (inside the outer boundary but outside all islands) has depth 0. This parity rule is identical to the even-odd fill rule used in SVG and PostScript rendering engines.
Associativity Mechanism
When associative hatching is enabled, AutoCAD stores persistent object handles (unique identifiers akin to pointers or UUIDs) linking the hatch entity to each boundary object in the drawing database. When any boundary object fires an edit event — a stretch, move, rotate, or scale — the reactor system triggers a re-evaluation of the hatch boundary. The engine recomputes the boundary loop and island hierarchy, regenerating the hatch pattern in place. If a boundary object is erased, the hatch loses associativity and becomes a static entity, accompanied by a warning. From a software architecture perspective, this is an implementation of the observer pattern: the hatch object subscribes to change notifications on its boundary objects and reacts accordingly.
ASSOCIATIVE LINK MODEL
Each handleᵢ is a persistent identifier (similar to a foreign key in database terms) pointing to a boundary object. If any referenced object is deleted or becomes an open curve, the association breaks and the hatch reverts to non-associative status.
Performance Note
HATCHGENERATEBOUNDARY and HPMAXLINES system variables to control pattern density and boundary caching.SECTION 5
Hatch Properties & Classification
Beyond island detection, AutoCAD's hatch system exposes a rich set of properties that govern appearance, behavior, and annotation semantics. Understanding these properties is essential for producing drawings that conform to industry standards (ANSI, ISO, DIN) and remain editable across project lifecycles. The diagram below maps the complete property taxonomy of a hatch entity.
| Property | Default Value | Typical Usage |
|---|---|---|
Pattern | ANSI31 | Standard 45° lines for general material sections per ANSI standards |
Scale | 1.0 | Adjust to match drawing scale; larger values spread lines apart, smaller values compress them |
Island Detection | Normal | Alternates fill/skip by nesting depth; most common for mechanical sections |
Associative | Yes | Keeps hatch synchronized with boundary edits; disable for static exports |
Gap Tolerance | 0 | Set to small positive value (e.g., 0.5) for imported or imprecise geometry |
Transparency | 0% | Increase to allow underlying geometry to show through hatched regions |
Common hatch properties and their defaults
SECTION 6
Worked Example — Hatching a Flanged Pipe Cross-Section
Consider a mechanical cross-section drawing of a flanged pipe. The geometry consists of an outer rectangular flange boundary, a circular pipe wall (the first island), and a circular pipe bore (a second-level island inside the pipe wall). We want to hatch the solid material — the flange body and the pipe wall — while leaving the pipe bore empty, precisely what the Normal island detection mode achieves. The hatch should be associative so that if the pipe diameter changes, the hatch updates automatically.
Creating an Associative Hatch with Normal Island Detection
- 1
Step 1 — Verify Geometry Closure
Before hatching, ensure all boundary objects form closed loops. Use theLISTcommand on each object and confirm it reports as "Closed." If any polyline has a small gap, join segments withPEDIT > Joinor increase the gap tolerance in the hatch settings. In this example, the rectangular flange is a closed polyline, and the two circles are inherently closed.All three boundaries confirmed closed ✓ - 2
Step 2 — Invoke the Hatch Command
TypeHATCHat the command line or click the Hatch button on the Home tab's Draw panel. The Hatch Creation contextual ribbon tab appears. Set the pattern toANSI31(the standard 45° line pattern for cast iron or general use), scale to1.0, and angle to0.Hatch Creation ribbon active with ANSI31 pattern loaded - 3
Step 3 — Configure Island Detection and Associativity
In the Options panel of the Hatch Creation ribbon, confirm that Associative is toggled ON (the chain-link icon should be highlighted). Click the Island Detection dropdown and select Normal. Alternatively, setHPISLANDDETECTION = 0at the command line (0 = Normal, 1 = Outer, 2 = Ignore).Island detection: Normal | Associative: ON - 4
Step 4 — Pick the Internal Point
Click inside the flange region (between the outer rectangle and the outer circle). AutoCAD's boundary detection algorithm casts rays, discovers the rectangular outer boundary and the two circular islands, and computes nesting depths: rectangle = depth 0 (fill), outer circle region = depth 1 (skip), inner bore = depth 2 (fill). Under Normal mode, the flange body (depth 0) and bore (depth 2) would both be hatched — but the bore is where we want empty space (the air passage). To correct this, we actually want just one pick point between the rectangle and the outer circle, which fills only the depth-0 annular region and the depth-2 material ring (pipe wall). The bore itself at depth 2 gets filled, which is correct since the pipe wall material between the two circles is at depth 1 (skipped by the outer circle island detection).Wait — let us re-analyze. The nesting: outer rectangle = boundary (depth 0, hatched), outer circle = island at depth 1 (skip), inner circle = sub-island at depth 2 (hatch). The region between the two circles (pipe wall) is at depth 1, so it is skipped. This is incorrect for our goal. - 5
Step 5 — Correct Approach: Multiple Pick Points
Since Normal mode skips the pipe wall (depth 1), we have two options. First, we can use Ignore mode with a pick point in the flange body so that the entire area except the bore is hatched. But this would also hatch the bore. The cleaner solution is to issue two separate hatch commands: one pick in the flange area (between rectangle and outer circle) using Outer detection, and a second pick in the pipe wall area (between the two circles) also using Outer detection. Alternatively, the most elegant solution uses Normal detection with the pick point in the flange area: depth 0 (flange) = hatched, depth 1 (pipe wall) = skipped, depth 2 (bore) = hatched. Then place a second hatch pick in the pipe wall region: here the outer circle is the boundary (depth 0 = hatched) and the inner circle is the island (depth 1 = skipped). This fills both the flange and the pipe wall while leaving the bore empty.Result: Two associative hatches fill the flange body and pipe wall; the bore remains empty ✓ - 6
Step 6 — Verify Associativity
Select the inner circle (pipe bore) and use theSCALEcommand to increase its radius by 20%. Observe that the pipe wall hatch automatically updates to reflect the new, thinner wall. Select each hatch and check the Properties palette: the "Associative" property should read "Yes." If you see "No," the boundary was modified in a way that broke the link (e.g., exploding the circle), and you will need to re-create the hatch.Both hatches dynamically update on boundary edit — associativity confirmed ✓
SECTION 7
Island Detection Mode Comparison
Choosing the correct island detection mode is a decision that depends on the specific annotation requirements of the drawing, the complexity of the boundary hierarchy, and the visual clarity needed by downstream consumers (fabricators, reviewers, or rendering engines). The following comparison table provides a structured decision framework.
| Criterion | Normal | Outer | Ignore |
|---|---|---|---|
| Fill Rule | Even-odd parity: alternates fill/skip at each nesting depth | Fills depth 0 only; all deeper regions are left empty | No parity check; all regions inside the outer boundary are filled regardless of islands |
| Best For | Mechanical cross-sections, multi-material assemblies, standard ANSI/ISO sections | Highlighting outer material only, such as walls in architectural plans or pipe flanges | Schematic diagrams, area fills for land use, solid color washes |
| Complexity Handling | Excellent for deeply nested islands (3+ levels) | Limited — ignores all interior detail beyond depth 1 | Simplest — bypasses island analysis entirely |
| Performance | Moderate — must compute full nesting hierarchy | Faster — stops after first island layer | Fastest — no island computation required |
| System Variable | HPISLANDDETECTION = 0 | HPISLANDDETECTION = 1 | HPISLANDDETECTION = 2 |
Comparison of the three island detection styles
KEY TAKEAWAY
fill-rule="evenodd"), Outer is a depth-limited variant, and Ignore is the nonzero winding rule applied without sign tracking. If you have implemented polygon rasterization in a graphics programming course, you already possess the algorithmic intuition for these modes. In practice, default to Normal unless a specific drawing standard or visual requirement dictates otherwise.SECTION 8
Connection to Advanced Theory — Parametric Hatching & API Access
The hatch concepts covered so far represent the interactive, GUI-driven workflow. For computer science students, the real power emerges when hatching is driven programmatically through AutoCAD's APIs — AutoLISP, .NET (C#), and ObjectARX (C++). These APIs expose the hatch entity as a programmable object with methods for setting patterns, appending boundary loops, controlling island detection, and toggling associativity. This enables automated annotation pipelines where hatching is applied as a post-processing step after parametric model generation.
| Feature | Interactive (GUI) | Programmatic (API) |
|---|---|---|
| Boundary Definition | Pick point or select objects in the viewport | Append loops via AppendLoop() method with explicit ObjectId collections; loop type (outer, inner) specified programmatically |
| Island Detection | Dropdown selection in Hatch Creation ribbon | Set HatchStyle property: HatchStyle.Normal, HatchStyle.Outer, HatchStyle.Ignore |
| Associativity | Toggle button on ribbon | Set Associative property to true/false; manage reactor callbacks for custom update logic |
| Batch Processing | Manual — one hatch at a time | Iterate over all block references or regions in a drawing; apply hatches in a loop with configurable parameters |
| Custom Patterns | Load from .pat files via the pattern browser | Define patterns programmatically with line-family specifications: angle, origin, delta, and dash arrays |
Interactive vs. Programmatic hatch workflows
Looking ahead, modern CAD platforms are integrating constraint-driven hatching where hatch properties (pattern, scale, color) are parametrically linked to material databases and BIM metadata. In Autodesk's Revit-AutoCAD interop workflows, a hatch pattern can be dynamically assigned based on the material property of a wall section — concrete gets ANSI37, steel gets ANSI32, and insulation gets ANSI35. For CS students interested in CAD software development, understanding the hatch entity's data model is a gateway to the broader domain of computational geometry annotation — the algorithmic layer that transforms raw geometry into human-readable technical documentation.
SECTION 9
Practice Problems
Question 1: CONCEPTUAL
Show answer
Question 2: BASIC CALCULATION
Show answer
Question 3: INTERMEDIATE
Show answer
Question 4: APPLIED
Show answer
Question 5: CRITICAL THINKING
Show answer
SUMMARY
Lesson Summary
Summary
AutoCAD's hatching system transforms closed geometric boundaries into annotated cross-sections through a three-component pipeline: boundary detection (ray-casting to discover enclosing loops), island detection (classifying nested internal boundaries by depth), and pattern generation (rendering line families within the computed fill regions). The three island detection styles — Normal (even-odd parity), Outer (depth-0 only), and Ignore (no island processing) — provide precise control over which nested regions receive fill, directly paralleling fill-rule algorithms from computer graphics.
Associative hatching maintains live links between hatch entities and boundary objects using the observer pattern, ensuring hatches update automatically when geometry changes. Key system variables (HPISLANDDETECTION, HPASSOC, HPGAPTOL) allow fine-tuned control from the command line, and the AutoCAD .NET API exposes the full hatch data model for programmatic automation — enabling batch hatching, parametric pattern assignment, and integration with BIM metadata pipelines.