CADLisp Tools

Dimensions & Annotation

Area Label AutoLISP routine

Place a text label containing a selected closed polyline's area. Download the .LSP source below and run the AREALABEL command after loading it.

⌘ AREALABELv1.0.0IntermediateUpdated Sep 18, 2026

What it does

Area Label with the AREALABEL AutoLISP command

Reads the enclosed area of one closed polyline, asks for a label point, and creates a plain TEXT value in drawing units.

AutoLISP command
AREALABEL
Difficulty
Intermediate

Applicable disciplines

CAD workflows that use this routine

Requirements and compatibility

What it needs

AutoLISPVisual LISPActiveX

Software rows marked “Not tested” are not compatibility claims. Test the routine in a copy of your drawing and CAD version.

Downloadable source code

Review the area-label.lsp AutoLISP code

area-label.lspAUTOLISP
;; CADLisp Tools - Area Label
(vl-load-com)

(defun ct-al:current-layer-writable-p (/ row flags color)
  (and (setq row (tblsearch "LAYER" (getvar "CLAYER")))
       (setq flags (cdr (assoc 70 row)) color (cdr (assoc 62 row)))
       (= 0 (logand flags 21))
       (>= color 0)))

(defun ct-al:2d-polyline-p (data / flags)
  (and data
       (or (= (cdr (assoc 0 data)) "LWPOLYLINE")
           (and (= (cdr (assoc 0 data)) "POLYLINE")
                (setq flags (cdr (assoc 70 data)))
                (= 0 (logand flags 88))))))

(defun ct-al:make-text (point value / height normal rotation ucs-x)
  (setq height (getvar "TEXTSIZE")
        normal (trans '(0.0 0.0 1.0) 1 0 T)
        ucs-x (trans '(1.0 0.0 0.0) 1 0 T)
        rotation (angle '(0.0 0.0 0.0) (trans ucs-x 0 normal T)))
  (entmakex
    (list '(0 . "TEXT")
          (cons 8 (getvar "CLAYER"))
          (cons 10 (trans point 0 normal))
          (cons 40 height)
          (cons 1 value)
          (cons 7 (getvar "TEXTSTYLE"))
          (cons 50 rotation)
          (cons 210 normal))))

(defun c:AREALABEL (/ *error* area closed data ent obj pick point result undo-started)
  (defun *error* (message)
    (if undo-started (command-s "_.UNDO" "_End"))
    (if (and message (not (wcmatch (strcase message) "*CANCEL*,*QUIT*,*EXIT*")))
      (prompt (strcat "\nAREALABEL error: " message)))
    (princ))
  (cond
    ((not (ct-al:current-layer-writable-p))
      (prompt "\nThe current layer is off, frozen, locked, or xref-dependent; no label created."))
    ((null (setq pick (entsel "\nPick a closed 2D polyline: ")))
      (prompt "\nNo polyline selected."))
    ((not (ct-al:2d-polyline-p (setq data (entget (setq ent (car pick))))))
      (prompt "\nThe selected object is not a supported 2D polyline."))
    ((or (vl-catch-all-error-p
           (setq closed (vl-catch-all-apply 'vlax-curve-isClosed (list ent))))
         (not closed))
      (prompt "\nThe selected polyline is open or invalid."))
    ((vl-catch-all-error-p
       (setq obj (vl-catch-all-apply 'vlax-ename->vla-object (list ent))))
      (prompt "\nThe selected polyline cannot be accessed through ActiveX."))
    ((vl-catch-all-error-p
       (setq result (vl-catch-all-apply 'vla-get-Area (list obj))))
      (prompt "\nThe selected polyline has no valid calculable area."))
    ((null (setq point (getpoint "\nLabel insertion point: ")))
      (prompt "\nNo insertion point supplied."))
    (T
      (setq area result point (trans point 1 0))
      (if (= 0 (logand 8 (getvar "UNDOCTL")))
        (progn (command "_.UNDO" "_Begin") (setq undo-started T)))
      (if (ct-al:make-text point (strcat "AREA=" (rtos area 2 3)))
        (prompt "\nArea label created.")
        (prompt "\nThe label could not be created."))
      (if undo-started (progn (command "_.UNDO" "_End") (setq undo-started nil)))))
  (princ))

Setup

How to install the area-label.lsp file

  1. 1Download and review the source code.
  2. 2Load the .lsp file with APPLOAD in a copy of a drawing.
  3. 3Keep the routine session-only until it has been tested for your CAD version and standards.

Command workflow

How to run the AREALABEL command

  1. 1Run AREALABEL.
  2. 2Pick a closed polyline.
  3. 3Pick the label insertion point.

Worked example

Example: Label a site boundary area.

  1. Run AREALABEL.
  2. Pick the boundary.
  3. Place the label.
Expected result

A text label shows the raw area in drawing units.

Read before use

Notes and limitations

  • Creates plain TEXT on the current layer and style.
  • Does not convert units or add fields.
  • Not manually CAD-tested.

Version history

Changelog

v1.0.0Sep 18, 2026Initial closed-polyline label routine.

Keep automating

Related tools

Geometry & Polylines6 disciplines

Closed Polyline Area

Sum the area of selected closed polylines and skip open ones.

⌘ CLOSEDARIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Dimensions & Annotation6 disciplines

Coordinate Label X/Y

Create a WCS X/Y text label at a picked coordinate.

⌘ XYLABELBeginnerCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Dimensions & Annotation2 disciplines

Room Area Label

Place a room-area text label from a selected closed polyline.

⌘ ROOMAREAIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →