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
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
;; 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
- 1Download and review the source code.
- 2Load the .lsp file with APPLOAD in a copy of a drawing.
- 3Keep the routine session-only until it has been tested for your CAD version and standards.
Command workflow
How to run the CLOSEDAR command
- 1Run CLOSEDAR.
- 2Select closed and open polylines.
- 3Read the valid total and skipped count.
Worked example
Example: Total three closed floor-zone boundaries.
- Run CLOSEDAR.
- Select the boundaries.
- Press Enter.
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