While the script above is a great starting point, professional-grade LISP routines often include:
Check your drawing units. The LISP returns the area based on the drawing's unit system (e.g., mm2m m squared inches2i n c h e s squared feet2f e e t squared
The goal is to create a command (let's call it TSA for "Total Selected Area") that will:
Replace the final princ lines with this: total area autocad lisp
Calculate only the areas of objects on a specific layer, ignoring everything else. Workflow Integration
If you are just starting with LISP, begin by searching for AreaM.lsp on CAD forums like CADTutor or the Autodesk Forums .
;; Offer to display in different units (initget "Yes No") (if (= (getkword "\nDisplay in different units? [Yes/No] <No>: ") "Yes") (progn (princ "\nSelect unit conversion:") (princ "\n 1 - Square feet") (princ "\n 2 - Square meters") (princ "\n 3 - Square yards") (initget 1 "1 2 3") (setq unit (getkword "\nEnter choice [1/2/3]: ")) (cond ((= unit "1") ; sq ft (setq converted (* total-area 144.0)) ; assuming drawing units in inches (princ (strcat "\nConverted: " (rtos converted 2 2) " sq ft"))) ((= unit "2") ; sq meters (setq converted (* total-area 0.00064516)) ; sq inches to sq meters (princ (strcat "\nConverted: " (rtos converted 2 2) " sq meters"))) ((= unit "3") ; sq yards (setq converted (* total-area 0.000771605)) ; sq inches to sq yards (princ (strcat "\nConverted: " (rtos converted 2 2) " sq yards"))) ) ) ) While the script above is a great starting
;; 4. Display the result (princ (strcat "\nTotal Area of " (itoa (sslength ss)) " objects: " (rtos total 2 2) " square units." ) ) ) (princ "\nNo objects selected.")
Many professionals store the conversion factor in a variable so they don't retype it every session.
You can enhance your LISP to subtract areas (e.g., courtyards from total building footprint) by selecting "negative" objects and subtracting from the sum. ;; Offer to display in different units (initget
Includes DSTP_AREASUM , a built-in function to calculate total areas of selected objects.
This article serves as a comprehensive guide to AutoLISP routines for calculating total area. We will explore why manual methods fall short, dissect the most popular free LISP routines available, provide step-by-step installation and usage instructions, and delve into advanced customization for professional workflows.
;; Copy total area to clipboard (optional) (initget "Yes No") (if (= (getkword "\nCopy total area to clipboard? [Yes/No] <No>: ") "Yes") (progn (setq area-str (rtos total-area 2 2)) (command "._SETENV" "Clipboard" area-str) (princ "\nTotal area copied to clipboard!") ) ) ) (princ "\nNo valid area objects selected.") ) ) )
These advanced scripts create an AutoCAD table, calculate the area of each parcel, and can export this data to Excel, perfect for subdivision plans.
If you are looking for a specific type of area calculation (e.g., net vs. gross), let me know, and I can provide a more tailored routine! Lisp to calculate area of all closed polylines selected