When working on large or complex AutoCAD drawings, you often need isolated temporary layers to test block placements, sort raw survey data, or isolate geometry for quick filtering. Manually opening the Layer Properties Manager, clicking "New Layer," and typing placeholder names repeatedly interrupts your drafting momentum.
The RLA.lsp (Random Layer Creator) routine automates bulk layer setup in seconds. It prompts you for the number of layers you need and generates unique, non-duplicating layer names using a dynamic time-based algorithm—giving you a clean sandbox without touching your main layer standards.
Key Benefits for CAD Workflows
Fast Sandboxing: Create 10, 20, or 50 isolated layers in a single command for quick testing, filtering, or temporary object separation.
Guaranteed Unique Names: Uses a system-time seed to construct distinct 8-character hexadecimal layer names (prefixed with
A$C), preventing naming collisions with existing drawing layers.Zero Template Pollution: Keeps temporary testing layers clearly distinct from your standard company layer template so you can easily purge or isolate them later.
How to Use RLA.lsp
Load
RLA.lspin AutoCAD using theAPPLOADcommand.Type
RLAin the command line and hit Enter.Enter the total number of temporary layers you want to generate (e.g.,
10).The script creates the layers in the background and confirms the total count in the command prompt.
AutoLISP Code (RLA.lsp)
Copy the code below and save it as RLA.lsp inside your AutoCAD support folder:
(defun c:RLA ( / num i randName seed hex c j old_error old_osmode acDoc )
(vl-load-com)
(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-StartUndoMark acDoc)
(setq old_osmode (getvar "OSMODE"))
(setq old_error *error*)
(defun *error* (msg)
(if old_osmode (setvar "OSMODE" old_osmode))
(vla-EndUndoMark acDoc)
(setq *error* old_error)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
(setq num (getint "\nEnter number of layers to create: "))
(if num
(progn
(setq i 1)
(while (<= i num)
(setq randName "A$C"
seed (fix (+ (* (rem (getvar "DATE") 1) 100000) i))
hex "0123456789ABCDEF"
j 0)
(while (< j 8)
(setq seed (rem (+ (* seed 17) 11) 99991))
(setq c (substr hex (1+ (rem seed 16)) 1))
(setq randName (strcat randName c))
(setq j (1+ j))
)
(if (not (tblsearch "LAYER" randName))
(entmake (list '(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 randName)
'(70 . 0)
'(62 . 7)
))
)
(setq i (1+ i))
)
(princ (strcat "\nSuccess: " (itoa num) " random layers have been created."))
)
)
(if old_osmode (setvar "OSMODE" old_osmode))
(vla-EndUndoMark acDoc)
(setq *error* old_error)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
Cleanup Tip
Once you finish your temporary testing or sorting, select the objects you want to keep, move them to your official project layers, and run the PURGE command to clear out all unreferenced A$C testing layers at once.

Post a Comment