AutoCAD’s DRAWORDER command works on selected objects. That is no use when the rule you actually want is “hatching behind everything, text in front of everything, survey base at the very back” — a rule about layers, not about particular objects. LAYERSTACK works the way the rule does.
What LayerStack does
A two-pane dialog: all layers on the left, the ones you want ordered on the right. Arrange the right-hand list into the order you want, then send that whole stack to the top or the bottom of the drawing.
The order of the right-hand list is the resulting draw order — the top of the list ends up in front.
Wildcard groups keep it manageable. The Add Pattern box accepts a wildcard, so *HATCH* adds every hatch layer as a single entry in the ordering list. On a long layer standard you order half a dozen patterns rather than eighty layers. The Filter box narrows the left-hand list the same way, which is how you find layers in a drawing that has hundreds.
How to use it
- Load the routine with
APPLOAD, or put it on your support file search path. - Type
LAYERSTACK. - Use the Filter box to find layers, or Add Pattern to add a whole group with a wildcard.
- Arrange the right-hand list so the layer that should be in front is at the top.
- Send the stack to the top or the bottom of the drawing.
How it works
Draw order lives in a SORTENTS table hanging off the space’s extension dictionary, and objects are moved within it. The table is created if the drawing does not have one yet.
The layer list is processed in reverse when sending to the top, and the reason is worth following. Each MoveToTop puts that layer in front of everything moved before it, so the last one moved ends up frontmost. Reversing the list makes the first entry finish in front — which is what the dialog implies, and what anyone would expect.
Getting that backwards would produce a result that is exactly inverted from what the display shows, which is the kind of bug people work around for years rather than report.
Notes and limits
- Top of the list means in front. The dialog order is the draw order.
- Use wildcards for a long standard.
*HATCH*as one entry beats eighty individual layers. - Xref-dependent layers are excluded — their draw order belongs to the referenced drawing.
- Draw order is per space. Model and each layout have their own.
Download and details
| Name | LayerStack — control draw order by layer rather than by object |
| Download | LayerStack.lsp — 35.4 KB, plain AutoLISP source. Downloads directly; no zip to unpack. |
| Type | AutoCAD AutoLISP routine |
| Command | LAYERSTACK |
| Requires | the ActiveX layer (loaded automatically by the routine with vl-load-com); nothing extra — the dialog is written to a temporary file at run time and deleted again, so there is no .dcl to install. |
| Source size | 35.4 KB, 752 lines |
| Error handling | Yes — a *error* handler restores every system variable it changed, on cancel as well as on error. |
| Undo | The whole operation is wrapped in a single undo group, so one U reverses all of it. |
| Compatibility | AutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer. |
| Author | YZ, August 2026 |
| Licence | Free to use, supplied “as is” with no warranty. |
References
- HATCHCLEAR LISP — when moving hatch behind text is not enough
- BACKDROP LISP — masking behind text as an alternative to reordering
- LAYERHARVEST LISP — audit what layers a set actually contains
- More free AutoLISP routines on this site
- Wisey’s Steel Shapes — free structural steel section drawing program