CADLISPMASTER
Stop wasting time on repetitive AutoCAD tasks. CAD LISP Master provides free, efficient AutoLISP codes and clear tutorials designed to automate your workflow and speed up your drafting.

AutoCAD X-Mark Generator: Draw Void & Opening Cross Lines

Draw cross lines and X-marks across voids or shaft openings in AutoCAD using SXX.lsp. Free AutoLISP script with 2-point diagonal and 4-point modes.
Draw Cross Lines / X-Marks Instantly

Indicating floor openings, elevator shafts, duct voids, or structural blockouts in AutoCAD always requires drawing diagonal X-marks. Doing this manually means activating the LINE command, snapping to four separate corners for every single opening, and switching line colors so the cross lines stand out from boundary walls. Across large floor plans with dozens of utility shafts, this manual clicking eats up a lot of drafting time.

The SXX.lsp (Structural Cross Lines) routine reduces this task to just two clicks. You pick two diagonal corners, and the script automatically calculates the bounding box and draws a centered X-mark. It also switches the cross line color to red (Color 1) for instant visual clarity, then restores your original drawing settings automatically.


Why Manually Drawing X-Marks Gets Frustrating

  • Too many clicks per opening: A standard 2-line X-mark requires picking 4 snap points. On a plan with 30 openings, that is over 120 precision clicks.

  • Misaligned snap points: In busy drawings, accidentally snapping to adjacent wall intersections instead of the actual void corner creates slanted, inaccurate marks.

  • Color switching hassle: If your redlines or opening marks need a specific color layer, changing active colors before and after drawing each mark breaks your drafting momentum.


How SXX.lsp Speeds Up Your Workflow

  • Diagonal Box Mode (2 Clicks): Simply pick the top-left and bottom-right points of any rectangular void. The script calculates the opposite corners and draws both diagonal lines instantly.

  • 4-Point Custom Mode: Working with non-rectangular or angled voids? Type 4P at the prompt to specify custom corner points sequentially.

  • Auto-Color Assignment: Draws the X-mark in crisp red (Color 1) for clear identification, then cleanly resets your active drawing color and system variables.


Step-by-Step Execution

  1. Load SXX.lsp into AutoCAD using the APPLOAD command.

  2. Type SXX in the command line and hit Enter.

  3. For standard rectangular openings: Click the first corner point, then click the opposite diagonal corner. The X-mark generates immediately.

  4. For irregular voids: Type 4P and press Enter, then pick your four corners sequentially (Top-Left > Bottom-Right > Top-Right > Bottom-Left).


AutoLISP Code (SXX.lsp)

Copy the code below and save it as SXX.lsp inside your AutoCAD support folder:

(defun c:SXX ( / p1 p2 oldecho oldcolor *error* pt1 pt2 pt3 pt4 acDoc )
  (vl-load-com)
  (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (defun *error* (msg)
    (if oldcolor (setvar "cecolor" oldcolor))
    (if oldecho (setvar "cmdecho" oldecho))
    (vla-EndUndoMark acDoc)
    (princ "\nCAD Lisp [www.daolpro.com]")
    (princ)
  )
  (setq oldecho (getvar "cmdecho"))
  (setq oldcolor (getvar "cecolor"))
  (setvar "cmdecho" 0)
  (vla-StartUndoMark acDoc)
  (setvar "cecolor" "1")
  (initget "4P")
  (setq p1 (getpoint "\nSpecify first diagonal point or [4P]: "))
  (cond
    ((= p1 "4P")
      (setq pt1 (getpoint "\nSpecify Top-Left point: "))
      (if pt1 (setq pt2 (getpoint pt1 "\nSpecify Bottom-Right point: ")))
      (if pt2 (setq pt3 (getpoint pt2 "\nSpecify Top-Right point: ")))
      (if pt3 (setq pt4 (getpoint pt3 "\nSpecify Bottom-Left point: ")))
      (if (and pt1 pt2 pt3 pt4)
        (progn
          (command "_.line" "_none" pt1 "_none" pt2 "")
          (command "_.line" "_none" pt3 "_none" pt4 "")
        )
      )
    )
    ((listp p1)
      (setq p2 (getcorner p1 "\nSpecify second diagonal point: "))
      (if p2
        (progn
          (command "_.line" "_none" p1 "_none" p2 "")
          (command "_.line" "_none" (list (car p2) (cadr p1) (caddr p1)) "_none" (list (car p1) (cadr p2) (caddr p2)) "")
        )
      )
    )
  )
  (setvar "cecolor" oldcolor)
  (vla-EndUndoMark acDoc)
  (setvar "cmdecho" oldecho)
  (princ "\nCAD Lisp [www.daolpro.com]")
  (princ)
)

Practical Drafting Note

If your office CAD standards require void lines to reside on a specific DEFPOINTS or VOID layer rather than an explicit color override, you can easily modify (setvar "cecolor" "1") in the code to target your preferred layer structure.

Post a Comment