AUTOCAD • ORGANIZATION AND LAYER MANAGEMENT

Draw Order — Control draw order of overlapping objects

Master the z-axis stacking hierarchy that determines how overlapping entities render and plot in AutoCAD drawings.

Historical Context & Motivation

In early versions of AutoCAD, the rendering pipeline was comparatively simple: objects were drawn to the screen in the order they were created in the database, and whichever entity was created last appeared on top. This implicit ordering sufficed when drawings contained only wireframe geometry—lines, arcs, and circles that could overlap without obscuring each other. However, as AutoCAD evolved to support solid fills, hatches, raster images, and wipeout objects, the question of which entity visually occludes another became critically important. The DRAWORDER command was introduced to give users explicit control over this stacking hierarchy, transforming draw order from an incidental artifact of creation sequence into a deliberate design decision.

1982
AutoCAD 1.0 Released
Autodesk releases AutoCAD 1.0 with a creation-order rendering pipeline. All entities are wireframe, so visual overlap is rarely problematic.
1997
DRAWORDER Command Introduced (R14)
AutoCAD Release 14 adds the DRAWORDER command, allowing users to send objects to the front or back and to place them above or below other objects in the display list.
2005
Annotative Objects & Enhanced Draw Order
AutoCAD 2006 refines draw order behavior for annotation objects, text masks, and wipeouts, making draw order essential for legible production drawings.
2012
DRAWORDER Enhancements
AutoCAD 2012 introduces the HPDRAWORDER system variable and per-hatch draw-order defaults, further integrating stacking control into the hatch workflow.
2020+
Modern Draw Order in Web & Cloud
AutoCAD Web and cloud-based viewers adopt GPU-accelerated compositing, but draw order remains a DWG-level property that must be explicitly managed for consistent output across platforms.

The central problem that draw order addresses is deceptively simple: given two or more entities that share the same X-Y coordinate space, which one should a human see on top? In a purely mathematical vector space, two overlapping filled regions are equivalent abstractions, but the moment they are rasterized to pixels on a screen or ink on a plotter, a deterministic stacking rule must resolve the ambiguity. Without explicit control, designers would be forced to delete and recreate objects in the correct sequence—a fragile, error-prone workflow that draw order eliminates entirely.

Core Principles & Definitions

Understanding draw order requires internalizing several foundational concepts that govern how AutoCAD's display engine resolves visual conflicts between overlapping entities. Although AutoCAD is fundamentally a 2D/3D CAD system, draw order operates independently of the Z-coordinate in 3D model space. Instead, it maintains a separate, abstract stacking index that controls compositing during rasterization. Think of it as a painter's algorithm applied at the entity level: the rendering engine paints entities from back to front, and each successive entity can overwrite the pixels of those beneath it.

1

Display List

An ordered sequence of entity handles maintained internally by AutoCAD. Each entity's position in this list determines its stacking priority during screen regeneration and plotting.
2

DRAWORDER Command

The primary command (alias: DR) for repositioning entities in the display list. It offers four options: Above, Below, Front, and Back.
3

SORTENTS System Variable

A bitcode integer (0–127) controlling which operations respect object sort order. Bits control selection, snap, redraw, plotting, PostScript output, regen, and more.
4

TEXTTOFRONT Command

A convenience command that sends all text, dimensions, or leader objects to the front of the draw order in a single operation—critical for legibility in dense drawings.
5

HPDRAWORDER Variable

Controls the default draw order assigned to newly created hatch objects. A value of 3 (send to back) is the default, ensuring hatches never obscure geometry.
KEY TAKEAWAY
Draw order in AutoCAD is analogous to the z-index property in CSS: just as a web developer uses z-index to control which HTML elements stack on top within the same stacking context, an AutoCAD user uses DRAWORDER to position entities within the display list. The key difference is that AutoCAD's draw order is a total ordering (every entity has a unique position), whereas CSS z-index allows ties that are then resolved by document flow—an important distinction for computer scientists accustomed to reasoning about partial vs. total orders.

Visual Explanation — The Stacking Model

The left panel depicts the internal display list as an ordered stack: index 0 is the back, and index 4 is the front. The right panel shows how these entities composite into a final rendered viewport. Notice how the text label at the top of the stack remains fully legible, while the hatch at the bottom is partially occluded by every other entity.

The diagram illustrates the fundamental mechanism: AutoCAD maintains a linear, totally ordered display list for each model-space or paper-space layout. When the viewport regenerates, the rendering engine iterates through this list from index 0 (back) to index n (front), painting each entity's pixels onto the frame buffer. Later entities overwrite earlier ones wherever they overlap—precisely the painter's algorithm from computer graphics. The DRAWORDER command modifies an entity's position in this list without altering any of its geometric or attribute data, making it a purely presentational operation that has no effect on coordinate geometry, block definitions, or external references.

How Draw Order Works Internally

Unlike many geometric properties in AutoCAD that map neatly to mathematical equations, draw order is best understood through its data-structure underpinnings. Internally, the DWG file format stores each entity with a handle—a persistent, unique identifier—and the display list is essentially a permutation of these handles that defines the rendering sequence. When you invoke DRAWORDER, AutoCAD performs a list reordering operation: it removes the selected entity handles from their current positions and reinserts them at the specified location (front, back, above a reference, or below a reference).

SORTENTS Bitcode Breakdown

The SORTENTS system variable is a bitfield that controls which AutoCAD operations respect the draw order. Each bit corresponds to a specific operation, and the variable's integer value is the sum of all enabled bits. Understanding this bitfield is essential for diagnosing cases where draw order appears to behave inconsistently across different operations.

SORTENTS bitfield: the default value of 127 enables all bits (1+2+4+8+16+32+64).
BitValueOperation ControlledEffect When Set
01Object selectionTopmost overlapping object is selected first
12Object snapSnap to the topmost overlapping endpoint
24Redraw / RegenDisplay regeneration respects draw order
38PlottingPlotted output respects draw order
416PostScript outputEPS/PS exports respect draw order
532Slide creationMSLIDE output respects draw order
664Render operationsRENDER command respects draw order
SORTENTS COMPUTATION
SORTENTS = Σ(2ⁱ) for each enabled bit i ∈ {0, 1, 2, 3, 4, 5, 6}
For example, enabling only object selection (bit 0), redraw (bit 2), and plotting (bit 3) yields SORTENTS = 2⁰ + 2² + 2³ = 1 + 4 + 8 = 13. This is a standard bitmask pattern familiar from Unix file permissions or TCP flags.
Performance Note
Setting SORTENTS to 0 disables all draw-order sorting, which can improve regeneration performance on drawings with tens of thousands of entities. However, this means overlapping objects will render in arbitrary (database) order. In production workflows, the default value of 127 is recommended to maintain visual consistency between screen and plot output.

DRAWORDER Commands & Classification

AutoCAD provides several commands and system variables for controlling draw order, each targeting a different scope or workflow. Understanding the taxonomy of these commands allows you to choose the most efficient tool for each scenario—ranging from repositioning a single hatch to globally sorting all text and dimensions to the top of the display list.

This taxonomy diagram categorizes the draw-order commands into three families: absolute positioning (Front/Back), relative positioning (Above/Below a reference entity), and convenience commands that batch-process specific entity types.
Primary draw-order commands and system variables in AutoCAD.
Command / VariableAliasScopeUse Case
DRAWORDERDRSelected objectsMove specific entities to front, back, above, or below another entity
TEXTTOFRONTAll text/dims globallyEnsure all annotation is readable above filled regions
HPDRAWORDERNew hatchesSet default draw order for hatches (0=none, 1=behind boundary, 2=in front, 3=send to back)
DRAWORDERCTLSystem-wideEnable/disable draw order (0=off, 1=on display only, 2=on except object selection, 3=all)

Worked Example — Fixing Overlapping Hatches and Text

Consider a common production scenario: you have a floor plan with room hatches (solid fills representing different materials), section-cut polylines, and room labels (MTEXT objects). After plotting, you notice that a concrete hatch obscures room label "A-105" and that the section-cut line disappears behind a carpet hatch. Here is the systematic workflow to resolve these draw-order conflicts.

Resolving Draw Order in a Floor Plan
1
Step 1 — Verify SORTENTSAt the command line, type SORTENTS and press Enter. Confirm the value is 127 (all bits enabled). If it is not, set it to 127 so that both the display and plot output will respect draw order changes.
SORTENTS = 127 (all operations respect draw order)
2
Step 2 — Send All Hatches to BackType DRAWORDER → select all hatch objects (you can use a crossing window and filter by entity type with QSELECT or the Properties palette) → press Enter → choose Back. This moves every hatch to the bottom of the display list.
All hatches are now at position 0..n in the display list
3
Step 3 — Bring Text and Dimensions to FrontType TEXTTOFRONT → select option Both (to include both text and dimensions). This is a global operation that repositions every text and dimension entity to the top of the display list in a single step.
All MTEXT, DTEXT, and dimension entities are now at the top of the display list
4
Step 4 — Position Section Lines Above Hatches but Below TextSelect the section-cut polylines → type DRAWORDER → choose Above → when prompted for a reference object, click on one of the hatch objects. The polylines will be inserted immediately above the hatches in the display list, below the text that was already sent to front.
Section lines render above hatches but remain below annotation
5
Step 5 — Verify and PlotType REGEN to force a complete screen regeneration and visually confirm the stacking order. Then produce a test plot (or use Plot Preview) to verify that the plotted output matches the screen. If SORTENTS bit 3 (value 8) is set, the plotter will respect the display list ordering.
Final stacking: Hatches → Lines → Section Cuts → Geometry → Text/Dimensions

Strengths, Limitations & Comparisons

AutoCAD's draw order system is effective but not without trade-offs. Comparing its capabilities to analogous systems in other software environments—and understanding its inherent limitations—helps practitioners make informed decisions about when draw order is the right tool and when alternative strategies (such as layer visibility or viewport overrides) may be more appropriate.

Strengths and limitations of AutoCAD's draw-order system.
AspectStrengthsLimitations
PrecisionTotal ordering guarantees deterministic rendering; no ambiguity about which entity is on top.Cannot assign numeric priority values (like CSS z-index); only relative/absolute positioning is available.
ScopeWorks across all entity types: lines, hatches, images, OLE objects, xrefs, blocks, text.Draw order is per-space (model vs. paper); cannot enforce cross-viewport ordering rules.
PerformanceSORTENTS = 0 can disable sorting entirely for maximum regeneration speed on large drawings.Sorting tens of thousands of entities on every regen introduces a measurable overhead proportional to n log n.
PersistenceDraw order is saved in the DWG file; consistent between sessions and across users.Copy-paste and WBLOCK operations may not preserve draw order; entities revert to creation order.
AutomationAccessible via AutoLISP, .NET API, and scripting for batch draw-order operations.No built-in rule engine (e.g., 'always keep layer X on top of layer Y'); automation must be scripted.
KEY TAKEAWAY
AutoCAD's draw order is a global total ordering on a flat list, whereas CSS z-index operates within nested stacking contexts and GPU-based game engines use depth buffers with floating-point z-values. If you need layer-based draw order rules (all entities on layer 'Annotation' above all entities on layer 'Hatch'), you must implement that logic via AutoLISP or the .NET API—AutoCAD will not enforce it declaratively. Understanding this architectural difference prevents frustration when migrating mental models between platforms.

Connection to Advanced Topics — Scripting & Automation

For computer science students, the natural extension of manual draw-order management is programmatic control. AutoCAD exposes draw-order manipulation through its AutoLISP scripting language and the .NET ObjectARX API. The DrawOrderTable object in the .NET API is conceptually similar to a doubly linked list that supports efficient insertion and removal at arbitrary positions—operations that map to the Above, Below, Front, and Back commands at the UI level.

Manual vs. scripted draw-order management.
FeatureManual (DRAWORDER)Scripted (AutoLISP / .NET)
GranularityOne entity or selection set at a timeBatch operations on filtered entity collections with arbitrary logic
Rule-based orderingNot supported; must be manually maintainedImplementable: e.g., sort all entities by layer name, then by entity type within each layer
IntegrationInteractive command lineEmbeddable in drawing templates, reactor events (e.g., on-save hooks), and CI/CD pipelines for drawing validation
ComplexityO(1) user effort per command invocationInitial development overhead but O(1) amortized effort per drawing thereafter
💻 AutoLISP Example
The following pseudocode sends all HATCH entities to the back of draw order programmatically: (defun c:HatchToBack () (ssget "X" '((0 . "HATCH"))) → draworder-sendtoback). In the .NET API, the equivalent uses DrawOrderTable.MoveToBottom(ObjectIdCollection). These approaches enable enforcement of organizational standards across large teams.

Looking further ahead, modern BIM (Building Information Modeling) platforms like Revit handle visual priority through view-level graphic overrides rather than a flat display list, and game engines use depth buffers (z-buffers) that resolve occlusion per-pixel in hardware. Understanding AutoCAD's simpler, entity-level approach provides a foundation for reasoning about these more sophisticated systems, much like understanding insertion sort helps one appreciate the optimizations in quicksort or timsort.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain why AutoCAD's draw order is described as a 'total ordering' rather than a 'partial ordering.' What property of the display list ensures this, and what would change if AutoCAD allowed ties (entities at the same draw-order position)?
PROBLEM 2BASIC CALCULATION
You want SORTENTS to control only object selection (bit 0), redraw/regen (bit 2), and plotting (bit 3). What integer value should you assign to SORTENTS? Show your calculation.
PROBLEM 3INTERMEDIATE
You have a drawing with the following entities in the current display list order (back to front): Hatch-A, Line-B, Image-C, Text-D, Hatch-E. You execute DRAWORDER on Hatch-E and choose 'Above' with Line-B as the reference object. Then you execute DRAWORDER on Text-D and choose 'Back.' Write the resulting display list order from back to front.
PROBLEM 4APPLIED
You are developing an AutoLISP script to enforce a company standard: all hatches on the 'A-FLOR-HATCH' layer must always render behind all geometry on the 'A-WALL' layer, which in turn must render behind all text on the 'A-ANNO-TEXT' layer. Describe the algorithm your script should follow, including which AutoCAD API calls or commands you would use, and analyze the time complexity in terms of the total number of entities n.
PROBLEM 5CRITICAL THINKING
AutoCAD's draw order uses a flat, entity-level display list, whereas a GPU-based depth buffer (z-buffer) resolves occlusion per-pixel using floating-point depth values. Discuss the trade-offs between these two approaches in terms of (a) memory consumption, (b) computational complexity per frame, (c) handling of transparency, and (d) suitability for 2D CAD versus real-time 3D rendering. Under what circumstances could a z-buffer approach be superior even in a 2D CAD context?

Summary — Draw Order in AutoCAD

AutoCAD's draw order system controls the visual stacking of overlapping entities by maintaining a display list—a totally ordered sequence of entity handles that the rendering engine traverses from back to front using the painter's algorithm. The DRAWORDER command (DR) provides four operations—Front, Back, Above, and Below—for repositioning entities within this list. The SORTENTS system variable is a 7-bit bitmask (default 127) that controls which operations—selection, snapping, regeneration, plotting, and others—respect the draw order.

Convenience commands like TEXTTOFRONT and the HPDRAWORDER variable streamline common workflows such as ensuring annotations remain legible and hatches stay behind geometry. For large-scale or standards-driven projects, draw order can be managed programmatically through AutoLISP or the .NET ObjectARX API, enabling rule-based, automated enforcement that scales across drawings and teams. Conceptually, draw order in AutoCAD is analogous to CSS z-index but operates as a flat total order rather than within nested stacking contexts—a distinction that is critical for computer scientists reasoning about rendering pipelines across platforms.

Varsity Tutors • AutoCAD • Draw Order — Control draw order of overlapping objects