This post shows a compact, reliable AutoLISP routine to calculate the total area of selected closed polylines and closed circle/ellipse-like objects in an AutoCAD drawing, plus instructions for loading and using it.
AutoLISP is a dialect of the Lisp programming language built specifically for automating tasks in AutoCAD. A Total Area Lisp is a script that automates the summation of area properties.
Instead of:
AREA > Add area > Object.The Lisp does this in one command: TOTAREA (or similar). You select 50 objects, press Enter, and it instantly tells you: Total Area = 2750.00 Sq. Ft. total area autocad lisp
Even the best Lisp routines can fail. Here are the top 5 errors and how to fix them.
| Error Message | Cause | Solution |
| :--- | :--- | :--- |
| "No valid objects selected" | You selected lines, arcs, or blocks. | Convert lines/arcs into a single Polyline (PEDIT command). Explode blocks first. |
| "; error: no function definition: VLAX-GET-AREA" | The Visual LISP extension is not loaded. | Type (vl-load-com) in the command line and press Enter, then retry TOTAREA. |
| Area = 0.00 | The polyline is self-intersecting or not closed. | Check the polyline property Closed = Yes. Use OVERKILL to clean up geometry. |
| Command: TOTAREA Unknown | The Lisp is not loaded correctly. | Re-run APPLOAD and ensure the file path is correct. Type (C:TOTAREA) manually. |
| Area is astronomically large | Your drawing units are in millimeters (1 unit = 1mm). | Divide total by 1,000,000 to get Sq. Meters. Or modify the Lisp to (/ total 1000000). |
TOTAREA.LSPCopy the following text exactly into a blank Notepad file. Save it with the name TOTAREA.LSP (ensure the extension is .lsp, not .txt). How to Create a Total Area AutoCAD LISP
;;; TOTAREA.LSP - Calculate total area of selected objects ;;; Command: TOTAREA ;;; Supports: LWPOLYLINE, CIRCLE, ELLIPSE, SPLINE, REGION, HATCH(defun C:TOTAREA ( / ss total area obj_name obj_list i ent) (princ "\nSelect objects to calculate total area: ")
;; Step 1: Create a selection set (setq ss (ssget '((0 . "LWPOLYLINE,CIRCLE,ELLIPSE,SPLINE,REGION,HATCH"))))
;; Step 2: Exit if nothing is selected (if (null ss) (princ "\nNo valid objects selected.") (progn (setq total 0.0) ; Initialize total to zero (setq i 0) ; Initialize counter Click AREA > Add area > Object
;; Step 3: Loop through each object in the selection set (repeat (sslength ss) (setq ent (ssname ss i)) ; Get entity name (setq obj_name (cdr (assoc 0 (entget ent)))) ; Get object type ;; Step 4: Calculate area based on object type (cond ;; For Polylines, Circles, Ellipses, Splines ((member obj_name '("LWPOLYLINE" "CIRCLE" "ELLIPSE" "SPLINE")) (command "_.AREA" "_Object" ent) (setq area (getvar "AREA")) ) ;; For Regions ((equal obj_name "REGION") (setq area (vla-get-area (vlax-ename->vla-object ent))) ) ;; For Hatches ((equal obj_name "HATCH") (setq area (vla-get-area (vlax-ename->vla-object ent))) ) ) ;; Step 5: Add area to total (if area (setq total (+ total area)) (princ (strcat "\nWarning: Could not compute area for object " (itoa i))) ) (setq i (1+ i)) ; Increment counter (setq area nil) ; Reset area variable ) ; end repeat ;; Step 6: Display the result (princ "\n=========================================") (princ (strcat "\n>>> TOTAL AREA: " (rtos total 2 2) " square units <<<")) (princ "\n=========================================") ) ; end progn
) ; end if (princ) ; Clean exit )
That small script saves me 5–10 minutes every day. Over a year? That’s nearly 40 hours of not re-clicking and re-adding.
More importantly: I never second-guess my area totals again. No manual math errors. No missing a polyline behind a hatch.
TOTAREA.LSPThe most widely circulated free LISP for this task is often called TOTAREA.LSP or ADDTOTALAREA.LSP. While many versions exist, the core functionality is consistent.