AUTOCAD • ANNOTATION AND DOCUMENTATION

Hatching with Islands — Create and edit hatch/fill with associative and island detection options

Master AutoCAD's hatch engine to fill complex nested boundaries with precision and associative intelligence.

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
The original HATCH command filled simple closed boundaries with predefined patterns. Island detection was absent — users had to manually trace sub-boundaries to avoid filling interior objects.
1997
AutoCAD R14 — BHATCH & Boundary Detection
The BHATCH command introduced automatic boundary detection using a flood-fill algorithm. Island detection modes (Normal, Outer, Ignore) appeared for the first time, allowing the engine to handle nested regions intelligently.
2004
AutoCAD 2005 — Associative Hatching
Associative hatching was fully realized: hatch objects dynamically updated when their bounding geometry changed. This linked the hatch entity to its boundary via persistent object references, dramatically improving edit workflows.
2011
AutoCAD 2012 — Ribbon-Based Hatch Creation
The contextual Hatch Creation ribbon tab replaced the legacy dialog box, offering real-time pattern previews, gradient fills, and streamlined island detection toggles accessible in a single toolbar.
2020
AutoCAD 2021 — Performance & Tolerance Enhancements
Modern releases introduced gap tolerance, improved boundary set handling, and better performance on large drawings with thousands of nested islands, leveraging multi-threaded boundary analysis.

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.

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.

1

Hatch Boundary

The outermost closed loop that defines the region to be filled. AutoCAD can detect this automatically from existing geometry via a pick-point or accept explicitly selected objects. The boundary must form a closed, non-self-intersecting loop.
2

Islands

Closed objects entirely contained within the outer boundary. Islands can be nested to arbitrary depth — an island within an island forms a sub-island. Each nesting level toggles the fill/no-fill state depending on the detection style selected.
3

Island Detection Styles

Three modes control how nested boundaries affect hatching: Normal (alternating fill/skip by nesting depth), Outer (fill only the outermost region), and Ignore (fill everything regardless of islands). These correspond to different parity rules in the fill algorithm.
4

Associative vs. Non-Associative

An associative hatch maintains a live link to its boundary objects. When the boundary geometry is stretched, moved, or edited, the hatch automatically regenerates. A non-associative hatch is a static snapshot — cheaper to store but requires manual re-hatching after edits.
5

Gap Tolerance

Real-world drawings often have small gaps in boundaries. Gap tolerance (0–5000 units) tells AutoCAD to treat near-closed loops as closed. This is analogous to an epsilon parameter in floating-point geometry comparisons — essential for robust boundary detection.
KEY TAKEAWAY
Think of island detection like a flood-fill algorithm on a bitmap: you click inside a region, and the fill spreads outward until it hits a boundary wall. Islands are walls within walls. The three detection styles (Normal, Outer, Ignore) are analogous to different recursion policies — Normal recurses and alternates, Outer recurses once and stops, and Ignore disables recursion entirely, filling the entire seed region uniformly. If you have implemented a recursive flood-fill in a graphics course, you already understand the core logic.

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.

The three panels share identical geometry: an outer rectangle (depth 0), a circle island (depth 1), and a square sub-island (depth 2). Normal mode alternates fill/skip at each depth. Outer mode fills only the outermost ring, leaving all interior regions empty. Ignore mode hatches everything as if no islands exist.

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.

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)
fill(region) = { HATCHED if depth mod 2 = 0, EMPTY if depth mod 2 = 1 }
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
HatchEntity → { handle₁, handle₂, …, handleₙ } → BoundaryObjects
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
In large drawings with hundreds of associative hatches, the reactor-based update mechanism can cause noticeable lag during editing operations. AutoCAD mitigates this with lazy evaluation: hatch regeneration is deferred until the display region is refreshed. You can further optimize by using HATCHGENERATEBOUNDARY and HPMAXLINES system variables to control pattern density and boundary caching.

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.

Complete property taxonomy of an AutoCAD hatch entity. The four categories — Pattern, Boundary, Behavior, and Display — map to distinct property groups in the Properties palette. Key system variables that control default hatch behavior are listed at the bottom.
Common hatch properties and their defaults
PropertyDefault ValueTypical Usage
PatternANSI31Standard 45° lines for general material sections per ANSI standards
Scale1.0Adjust to match drawing scale; larger values spread lines apart, smaller values compress them
Island DetectionNormalAlternates fill/skip by nesting depth; most common for mechanical sections
AssociativeYesKeeps hatch synchronized with boundary edits; disable for static exports
Gap Tolerance0Set to small positive value (e.g., 0.5) for imported or imprecise geometry
Transparency0%Increase to allow underlying geometry to show through hatched regions

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 ClosureBefore hatching, ensure all boundary objects form closed loops. Use the LIST command on each object and confirm it reports as "Closed." If any polyline has a small gap, join segments with PEDIT > Join or 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 CommandType HATCH at 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 to ANSI31 (the standard 45° line pattern for cast iron or general use), scale to 1.0, and angle to 0.
Hatch Creation ribbon active with ANSI31 pattern loaded
3
Step 3 — Configure Island Detection and AssociativityIn 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, set HPISLANDDETECTION = 0 at the command line (0 = Normal, 1 = Outer, 2 = Ignore).
Island detection: Normal | Associative: ON
4
Step 4 — Pick the Internal PointClick 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 PointsSince 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 AssociativitySelect the inner circle (pipe bore) and use the SCALE command 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 ✓

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.

Comparison of the three island detection styles
CriterionNormalOuterIgnore
Fill RuleEven-odd parity: alternates fill/skip at each nesting depthFills depth 0 only; all deeper regions are left emptyNo parity check; all regions inside the outer boundary are filled regardless of islands
Best ForMechanical cross-sections, multi-material assemblies, standard ANSI/ISO sectionsHighlighting outer material only, such as walls in architectural plans or pipe flangesSchematic diagrams, area fills for land use, solid color washes
Complexity HandlingExcellent for deeply nested islands (3+ levels)Limited — ignores all interior detail beyond depth 1Simplest — bypasses island analysis entirely
PerformanceModerate — must compute full nesting hierarchyFaster — stops after first island layerFastest — no island computation required
System VariableHPISLANDDETECTION = 0HPISLANDDETECTION = 1HPISLANDDETECTION = 2
KEY TAKEAWAY
The three island detection modes map directly to fill-rule concepts in vector graphics: Normal is the even-odd rule (used in SVG's 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.

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.

Interactive vs. Programmatic hatch workflows
FeatureInteractive (GUI)Programmatic (API)
Boundary DefinitionPick point or select objects in the viewportAppend loops via AppendLoop() method with explicit ObjectId collections; loop type (outer, inner) specified programmatically
Island DetectionDropdown selection in Hatch Creation ribbonSet HatchStyle property: HatchStyle.Normal, HatchStyle.Outer, HatchStyle.Ignore
AssociativityToggle button on ribbonSet Associative property to true/false; manage reactor callbacks for custom update logic
Batch ProcessingManual — one hatch at a timeIterate over all block references or regions in a drawing; apply hatches in a loop with configurable parameters
Custom PatternsLoad from .pat files via the pattern browserDefine patterns programmatically with line-family specifications: angle, origin, delta, and dash arrays

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.

Practice Problems

PROBLEM 1CONCEPTUAL
A drawing contains a large circle with two smaller, non-overlapping circles inside it (side by side, not nested within each other). Using Normal island detection, you pick a point inside the large circle but outside both smaller circles. Describe which regions will be hatched and which will be left empty. Then explain how the result would differ if you switched to Outer mode.
PROBLEM 2BASIC CALCULATION
A rectangular boundary measures 200 × 100 drawing units. Inside it, there is one circular island with radius 30 units. You apply a hatch using the ANSI31 pattern with a scale of 1.0 (line spacing = 3.175 mm at default). Using Normal island detection, compute the approximate area that will be hatched. Express your answer in square drawing units.
PROBLEM 3INTERMEDIATE
You have a drawing with a closed polyline forming an L-shaped boundary. Inside the L-shape, there are three circles: Circle A is entirely within the L-shape, Circle B overlaps the L-shape boundary (partially inside, partially outside), and Circle C is entirely outside the L-shape. You invoke HATCH with a pick point inside the L-shape. Describe the expected behavior for each circle regarding island detection, and explain what error or warning AutoCAD might generate for Circle B.
PROBLEM 4APPLIED
You are developing a C# plugin using the AutoCAD .NET API to automate hatching of floor plan rooms. Each room is represented by a closed polyline, and interior columns are represented by small closed rectangles. Write pseudocode that iterates over all rooms, creates an associative hatch for each one using Normal island detection with the ANSI37 pattern, and appends any columns found within the room boundary as island loops.
PROBLEM 5CRITICAL THINKING
AutoCAD's associative hatching uses an observer pattern where the hatch entity subscribes to modification events on its boundary objects. Discuss the trade-offs of this design compared to an alternative approach where hatches are regenerated lazily only when the drawing is saved or plotted. Consider memory usage, responsiveness, correctness guarantees, and edge cases such as undo/redo operations and circular dependencies.

Lesson 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.

Varsity Tutors • AutoCAD • Hatching with Islands — Create and edit hatch/fill with associative and island detection options