AutoCAD Tip: Attach Lightweight XData Metadata to AutoCAD Objects with AutoLISP

May 18, 2026 2 min read

AutoCAD Tip: Attach Lightweight XData Metadata to AutoCAD Objects with AutoLISP

Attach extended data (XData) to objects to carry lightweight metadata that travels with your geometry. It’s ideal for IDs, specs, and statuses without cluttering layers or attributes. If you manage standards or automation, XData is a precise, scriptable way to embed meaning in your drawings. For licensing, training, and deployment support, connect with NOVEDGE.

  • When to use XData
    • Tag objects with IDs, phase codes, or material names.
    • Store flags for automation (e.g., “to-fab”, “QC-pending”).
    • Keep metadata invisible and non-plotting, yet queryable.
    • Prefer XData for small, fast, per-object key–values.
    • Choose Xrecords in Extension Dictionaries for larger or hierarchical data.
  • Plan a tiny schema before you start
    • Define a unique application name, e.g., “MYCO:ASSET”.
    • List keys and value types (text, integer, real, point).
    • Decide update rules (who/what can overwrite values).
    • Document it in your CAD standards and templates.

Attach XData with a minimal, reliable AutoLISP pattern:

;; Register your application name once per drawing
(regapp "MYCO:ASSET")

;; Attach or update XData on a selected object
(defun c:TAG-ASSET ( / e d)
  (setq e (car (entsel "\nSelect object to tag: ")))
  (if e
    (progn
      (setq d (entget e))
      (entmod
        (append d
          (list
            (list -3
              (list
                "MYCO:ASSET"
                (cons 1000 "Tag=Beam")
                (cons 1070 12)     ;; integer (e.g., revision)
                (cons 1040 3.1415) ;; real (e.g., thickness)
              )
            )
          )
        )
      )
      (prin1 "\nXData attached.")
    )
  )
  (princ)
)

Retrieve and filter by XData in scripts:

;; Read back only MYCO:ASSET XData
(setq e  (car (entsel "\nPick: ")))
(setq xd (assoc -3 (entget e '("MYCO:ASSET"))))
;; xd => (-3 ("MYCO:ASSET" (1000 . "Tag=Beam") (1070 . 12) (1040 . 3.1415)))

;; Build a selection set of objects where (1070 . 12)
(setq ss (ssget "_X" (list (list -3 (list "MYCO:ASSET" (cons 1070 12))))))
  • Maintenance and performance tips
    • Keep values concise; XData per app is limited (~16 KB). Use multiple 1000 codes if you must split long text.
    • Namespaced AppName (e.g., “MYCO:ASSET”) prevents collisions with other teams.
    • Use FILTER’s Xdata tab for quick, UI-based searches; Quick Select won’t see XData.
    • Purge stray RegApps: -PURGE ➜ Regapps ➜ * ➜ No (don’t verify each name).
  • Quality and collaboration
    • Lock down allowed values with small helper commands (e.g., TAG-SET, TAG-GET, TAG-CLEAR).
    • Log writes/edits in the command line for auditability.
    • Package your LISP and CUI with your templates so teams apply XData consistently.
    • If you need more than lightweight tags, store a handle in XData (1005) and keep rich data in an external file or Xrecord.

Standardizing your XData workflow boosts selection, automation, and downstream reporting while keeping drawings lean. For expert guidance, enterprise licensing, and recommended plugins, partner with NOVEDGE.



You can find all the AutoCAD products on the NOVEDGE web site at this page.







Also in Design News

Subscribe

How can I assist you?