CADLisp Tools

Geometry & Polylines

Closed Polyline Area AutoLISP routine

Sum the area of selected closed polylines and skip open ones. Download the .LSP source below and run the CLOSEDAR command after loading it.

⌘ CLOSEDARv1.0.0IntermediateUpdated Sep 18, 2026

What it does

Closed Polyline Area with the CLOSEDAR AutoLISP command

Checks each selected polyline for closure, totals valid enclosed areas, and reports how many open curves were skipped.

AutoLISP command
CLOSEDAR
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 closed-polyline-area.lsp AutoLISP code

closed-polyline-area.lspAUTOLISP
;; CADLisp Tools - Closed Polyline Area
(vl-load-com)

(defun ct-ca: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-ca:area (ent / closed data obj result)
  (setq data (and ent (entget ent)))
  (if (and (ct-ca:2d-polyline-p data)
           (not (vl-catch-all-error-p
                  (setq closed (vl-catch-all-apply 'vlax-curve-isClosed (list ent)))))
           closed
           (not (vl-catch-all-error-p
                  (setq obj (vl-catch-all-apply 'vlax-ename->vla-object (list ent)))))
           (not (vl-catch-all-error-p
                  (setq result (vl-catch-all-apply 'vla-get-Area (list obj))))))
    result))

(defun c:CLOSEDAR (/ area ent i skipped ss total)
  (prompt "\nSelect 2D polylines: ")
  (if (setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE"))))
    (progn
      (setq total 0.0 skipped 0)
      (repeat (setq i (sslength ss))
        (setq ent (ssname ss (setq i (1- i))) area (ct-ca:area ent))
        (if area
          (setq total (+ total area))
          (setq skipped (1+ skipped))))
      (prompt (strcat "\nClosed area total: " (rtos total 2 3)
                      "; unsupported, open, or invalid polylines skipped: " (itoa skipped))))
    (prompt "\nNo polylines selected."))
  (princ))

Setup

How to install the closed-polyline-area.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 CLOSEDAR command

  1. 1Run CLOSEDAR.
  2. 2Select closed and open polylines.
  3. 3Read the valid total and skipped count.

Worked example

Example: Total three closed floor-zone boundaries.

  1. Run CLOSEDAR.
  2. Select the boundaries.
  3. Press Enter.
Expected result

The closed areas are summed; open curves are reported as skipped.

Read before use

Notes and limitations

  • Reports raw drawing-unit area.
  • Self-intersecting boundaries may return unexpected values.
  • Not manually CAD-tested.

Version history

Changelog

v1.0.0Sep 18, 2026Initial closed-curve area total routine.

Keep automating

Related tools

Dimensions & Annotation5 disciplines

Area Label

Place a text label containing a selected closed polyline's area.

⌘ AREALABELIntermediateCAD 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 →
Geometry & Polylines6 disciplines

Total Polyline Length

Calculate the combined length of selected 2D and legacy polylines.

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