Quick Access Search All Tools Ctrl+K Help & Tool Guide
Method 1 — Load via APPLOAD
  1. Copy a snippet and save as myscript.lsp in any folder
  2. Type APPLOAD at the AutoCAD command prompt
  3. Browse to your .lsp file → click Load
  4. Type the command (e.g. CLEANUP) to run it
Method 2 — Drag & Drop
  1. Save snippet as a .lsp file
  2. Drag the file directly onto an open AutoCAD drawing window
  3. AutoCAD loads it automatically — type the command to run
Auto-Load on Startup
  1. Place your .lsp files in the AutoCAD Support folder
  2. Add them to acad.lsp or acaddoc.lsp to auto-load
  3. Or use APPLOAD → Startup Suite → Contents
⚠ SECURELOAD setting may restrict loading from untrusted paths
SLC — Set Layer Current Layer
Pick any object to instantly make its layer the current layer. Faster than the Layer Manager for quick switches.
(defun c:SLC (/ ent)
  (setq ent (car (entsel "\nPick object to set layer current: ")))
  (if ent
    (setvar "CLAYER"
      (cdr (assoc 8 (entget ent))))
    (princ "\nNo object selected.")
  )
  (princ)
)
ISOL — Isolate Layer Layer
Pick one object — freezes every other layer, leaving only that object's layer visible. Equivalent to LAYISO but without the dialog.
(defun c:ISOL (/ ent lyr)
  (setq ent (car (entsel "\nPick object on layer to isolate: ")))
  (if ent
    (progn
      (setq lyr (cdr (assoc 8 (entget ent))))
      (command "LAYER" "FREEZE" "*" "" "THAW" lyr "")
      (princ (strcat "\n✓ Isolated: " lyr))
    )
    (princ "\nCancelled.")
  )
  (princ)
)
FRZOTHER — Freeze All Others Layer
Freezes every layer except the one currently active. Useful when you want to work on a single layer without picking an object.
(defun c:FRZOTHER (/ cur)
  (setq cur (getvar "CLAYER"))
  (command "LAYER" "FREEZE" "*" "" "THAW" cur "")
  (princ (strcat "\n✓ All layers frozen except: " cur))
  (princ)
)
TO0 — Move Selection to Layer 0 Layer
Moves all selected objects to Layer 0. Handy when preparing geometry for blocks that need to inherit the insertion layer's properties.
(defun c:TO0 (/ ss i ent)
  (setq ss (ssget))
  (if ss
    (progn
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (entmod (subst (cons 8 "0")
                       (assoc 8 (entget ent))
                       (entget ent)))
        (setq i (1+ i))
      )
      (princ (strcat "\n✓ " (itoa (sslength ss)) " objects moved to Layer 0."))
    )
    (princ "\nNothing selected.")
  )
  (princ)
)
UTILLAYERS — Create Utility Layer Set Utility
Creates a standard utility/electrical layer set in one command: CONDUCTOR, POLE, GUY-WIRE, XFMR, GROUND, and LABELS — each with color and linetype assigned.
(defun c:UTILLAYERS ()
  ; (layer-name color linetype)
  (foreach lyr '(
    ("CONDUCTOR" "3" "Continuous")
    ("POLE"      "5" "Continuous")
    ("GUY-WIRE"  "1" "Dashed")
    ("XFMR"      "4" "Continuous")
    ("GROUND"    "6" "Continuous")
    ("LABELS"    "7" "Continuous")
  )
    (command "LAYER" "MAKE" (car lyr)
             "COLOR"  (cadr lyr)   (car lyr)
             "LTYPE"  (caddr lyr)  (car lyr) "")
  )
  (princ "\n✓ Utility layer set created.")
  (princ)
)
CTH — Change Text Height Text
Select any number of TEXT or MTEXT objects and set them all to a new height in one operation. Works across mixed text types.
(defun c:CTH (/ ss ht i ent)
  (setq ht (getreal "\nNew text height: "))
  (setq ss (ssget '((0 . "TEXT,MTEXT"))))
  (if (and ss ht)
    (progn
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (entmod (subst (cons 40 ht)
                       (assoc 40 (entget ent))
                       (entget ent)))
        (setq i (1+ i))
      )
      (princ (strcat "\n✓ " (itoa (sslength ss)) " text objects updated."))
    )
    (princ "\nCancelled.")
  )
  (princ)
)
ADDPREFIX — Prefix All Selected Text Text
Adds a prefix string to the front of every selected TEXT object. Useful for quickly batch-labeling — e.g. turning "101" into "POLE-101".
(defun c:ADDPREFIX (/ ss prefix i ent str)
  (setq prefix (getstring T "\nPrefix string to add: "))
  (setq ss (ssget '((0 . "TEXT"))))
  (if (and ss prefix)
    (progn
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (setq str (cdr (assoc 1 (entget ent))))
        (entmod (subst (cons 1 (strcat prefix str))
                       (assoc 1 (entget ent))
                       (entget ent)))
        (setq i (1+ i))
      )
      (princ (strcat "\n✓ Prefix added to "
                     (itoa (sslength ss)) " objects."))
    )
  )
  (princ)
)
CLEANUP — Purge + Audit Cleanup
Runs PURGE (removes unused layers, blocks, styles, linetypes) then AUDIT (fixes database errors) in one command. Run before sending drawings to others.
(defun c:CLEANUP ()
  (command "PURGE" "A" "" "N")
  (command "AUDIT" "Y")
  (princ "\n✓ Purge + Audit complete.")
  (princ)
)
CLEANDUPS — Remove Overlapping Objects Cleanup
Calls the built-in OVERKILL command with default tolerances to delete duplicate and overlapping lines, arcs, and polylines from the entire drawing.
(defun c:CLEANDUPS (/ ss)
  (setq ss (ssget "X"))       ; select all in drawing
  (if ss
    (progn
      (command "OVERKILL" ss "" )
      (princ "\n✓ Duplicate/overlapping objects removed.")
    )
    (princ "\nDrawing is empty.")
  )
  (princ)
)
ATTREP — Attribute Find & Replace Block
Searches all block attributes in the drawing for a matching value and replaces it. Useful for updating pole numbers, circuit IDs, or drawing numbers across a sheet.
(defun c:ATTREP (/ ss find rep i ent att)
  (setq find (getstring T "\nFind attribute value: "))
  (setq rep  (getstring T "\nReplace with: "))
  (setq ss (ssget "X" '((0 . "INSERT") (66 . 1))))
  (if ss
    (progn
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (setq att (entnext ent))
        (while (= "ATTRIB" (cdr (assoc 0 (entget att))))
          (if (= find (cdr (assoc 1 (entget att))))
            (entmod (subst (cons 1 rep)
                           (assoc 1 (entget att))
                           (entget att)))
          )
          (setq att (entnext att))
        )
        (setq i (1+ i))
      )
      (princ "\n✓ Attribute replacement complete.")
    )
    (princ "\nNo blocks with attributes found.")
  )
  (princ)
)
CD — Circle by Diameter Draw
Draws a circle by entering diameter instead of radius. AutoCAD's CIRCLE command requires a radius — this wrapper lets you type the diameter naturally.
(defun c:CD (/ ctr dia)
  (setq ctr (getpoint "\nCenter point: "))
  (setq dia (getreal "\nDiameter: "))
  (if (and ctr dia (> dia 0))
    (command "CIRCLE" ctr (/ dia 2))
    (princ "\nInvalid input.")
  )
  (princ)
)
SCALEREF — Scale by Reference Distance Draw
Scale selected objects using a known reference distance and target distance. Calculates the scale factor automatically — no math required.
(defun c:SCALEREF (/ ss bp ref new sf)
  (setq ss  (ssget))
  (setq bp  (getpoint "\nBase point: "))
  (setq ref (getreal  "\nKnown (reference) distance: "))
  (setq new (getreal  "\nDesired (new) distance: "))
  (if (and ss bp ref new (/= ref 0))
    (progn
      (setq sf (/ new ref))
      (command "SCALE" ss "" bp sf)
      (princ (strcat "\n✓ Scale factor applied: "
                     (rtos sf 2 4)))
    )
    (princ "\nCancelled or invalid input.")
  )
  (princ)
)
COUNTOBJ — Count Selected Objects Selection
Select any objects and get an instant count at the command line. Also breaks down the count by entity type (LINE, INSERT, TEXT, etc.).
(defun c:COUNTOBJ (/ ss i ent typ tbl)
  (setq ss (ssget))
  (if ss
    (progn
      (setq i 0 tbl (list))
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (setq typ (cdr (assoc 0 (entget ent))))
        (if (assoc typ tbl)
          (setq tbl (subst (cons typ (1+ (cdr (assoc typ tbl))))
                           (assoc typ tbl) tbl))
          (setq tbl (append tbl (list (cons typ 1))))
        )
        (setq i (1+ i))
      )
      (princ (strcat "\nTotal: " (itoa (sslength ss)) " objects"))
      (foreach pair tbl
        (princ (strcat "\n  " (car pair) ": " (itoa (cdr pair))))
      )
    )
    (princ "\nNothing selected.")
  )
  (princ)
)
SCALEINFO — Drawing Scale & Units Info Info
Prints a summary of the current drawing's name, unit type, drawing limits, and annotation scale to the command line. Quick sanity check when opening an unfamiliar file.
(defun c:SCALEINFO (/ ul)
  (setq ul (getvar "LUNITS"))
  (princ (strcat
    "\n── Drawing Info ──────────────────"
    "\n  File:        " (getvar "DWGNAME")
    "\n  Unit Type:   " (nth (1- ul)
                         '("Scientific" "Decimal" "Engineering"
                           "Architectural" "Fractional"))
    "\n  Limits Min:  "
      (rtos (car  (getvar "LIMMIN")) 2 4) ","
      (rtos (cadr (getvar "LIMMIN")) 2 4)
    "\n  Limits Max:  "
      (rtos (car  (getvar "LIMMAX")) 2 4) ","
      (rtos (cadr (getvar "LIMMAX")) 2 4)
    "\n  Annot Scale: " (getvar "CANNOSCALEVALUE")
    "\n  Current Lyr: " (getvar "CLAYER")
    "\n──────────────────────────────────"
  ))
  (princ)
)
LISTLAYERS — Print All Layer Names Info
Prints every layer name in the drawing to the command line window — including frozen and off layers. Useful for auditing a file you didn't set up.
(defun c:LISTLAYERS (/ doc layers count)
  (vl-load-com)
  (setq doc    (vla-get-ActiveDocument (vlax-get-acad-object)))
  (setq layers (vla-get-Layers doc))
  (setq count  0)
  (vlax-for lyr layers
    (princ (strcat "\n  " (vla-get-Name lyr)))
    (setq count (1+ count))
  )
  (princ (strcat "\n── " (itoa count) " layers total ──"))
  (princ)
)
SPAN — Draw Span & Label Distance Utility
Pick two pole locations — draws the span line and places a centered label showing the span distance. Distance is calculated and formatted automatically.
(defun c:SPAN (/ p1 p2 mid dist ang)
  (setq p1 (getpoint "\nPole 1 location: "))
  (setq p2 (getpoint p1 "\nPole 2 location: "))
  (setq dist (distance p1 p2))
  (setq mid  (list (/ (+ (car p1)  (car p2))  2)
                   (/ (+ (cadr p1) (cadr p2)) 2) 0))
  (setq ang  (angle p1 p2))
  ; Draw span line on CONDUCTOR layer
  (command "LAYER" "MAKE" "CONDUCTOR" "")
  (command "LINE" p1 p2 "")
  ; Label at midpoint
  (command "LAYER" "MAKE" "LABELS" "")
  (command "TEXT" "J" "MC" mid (* dist 0.03)
           (angtos ang 0 0)
           (strcat (rtos dist 2 1) "'"))
  (princ (strcat "\n✓ Span: " (rtos dist 2 2) " ft"))
  (princ)
)
POLE — Place Pole Marker Utility
Picks a pole location and draws a standard utility pole symbol (circle + center point) on the POLE layer. Prompts for a pole number label.
(defun c:POLE (/ pt num)
  (setq pt  (getpoint "\nPole location: "))
  (setq num (getstring "\nPole number (Enter to skip): "))
  ; Switch to POLE layer — creates it if it doesn't exist
  (command "LAYER" "MAKE" "POLE" "COLOR" "5" "POLE" "")
  (command "CIRCLE" pt 0.5)
  (command "POINT" pt)
  ; Optional label
  (if (/= num "")
    (progn
      (command "LAYER" "MAKE" "LABELS" "COLOR" "7" "LABELS" "")
      (command "TEXT" "J" "MC"
               (list (car pt) (+ (cadr pt) 0.75) 0)
               0.18 "0" num)
    )
  )
  (princ (strcat "\n✓ Pole placed" (if (/= num "") (strcat ": " num) ".") ))
  (princ)
)
GUY — Draw Guy Wire Utility
Picks a pole attachment point and anchor point, draws the guy wire as a dashed line on the GUY-WIRE layer. Automatically assigns the correct linetype.
(defun c:GUY (/ p1 p2)
  (setq p1 (getpoint "\nPole attachment point: "))
  (setq p2 (getpoint p1 "\nAnchor/deadman point: "))
  (command "LAYER" "MAKE" "GUY-WIRE"
           "COLOR" "1" "GUY-WIRE"
           "LTYPE" "Dashed" "GUY-WIRE" "")
  (command "LINE" p1 p2 "")
  (princ (strcat "\n✓ Guy wire drawn. Length: "
                 (rtos (distance p1 p2) 2 2) " ft"))
  (princ)
)
SAVEBAK — Quick Save with Confirmation File
Saves the current drawing and prints the filename and save path to the command line — useful when you need a quick audit trail of when a save occurred.
(defun c:SAVEBAK (/ dwg path)
  (setq dwg  (getvar "DWGNAME"))
  (setq path (getvar "DWGPREFIX"))
  (command "QSAVE")
  (princ (strcat
    "\n✓ Saved: " dwg
    "\n  Path:  " path
  ))
  (princ)
)
ZE — Zoom Extents Cleanup
Fits the entire drawing into the viewport — identical to the built-in ZOOM E, but faster to type. Load this once and ZE becomes a one-keystroke command.
(defun c:ZE ()
  (command "ZOOM" "E")
  (princ)
)