Total Area Autocad | Lisp
ReelsVideo.io

Total Area Autocad | Lisp

;; Alternative: Quick total area with selection window (defun C:TAQ ( / ss total area obj) (setq ss (ssget '((0 . "CIRCLE,ARC,ELLIPSE,LWPOLYLINE,POLYLINE,REGION,HATCH")))) (setq total 0.0) (if ss (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (if (vlax-property-available-p obj "Area") (setq total (+ total (vla-get-area obj))) ) ) ) (princ (strcat "\nTotal Area = " (rtos total 2 2))) (princ) )

If you edit shapes after putting a total area field, use the REGEN command to update the total.

;; 4. Display the result (princ (strcat "\nTotal Area of " (itoa (sslength ss)) " objects: " (rtos total 2 2) " square units." ) ) ) (princ "\nNo objects selected.")

: Sum dozens of separate enclaves or rooms in two clicks instead of hours of manual addition. total area autocad lisp

In the dialog box, browse to locate your saved TotalArea.lsp file.

the command:

Below is a clean, optimized, and fully functional AutoLISP script. This routine allows you to select multiple closed polylines, circles, regions, or ellipses, calculates their total area, and gives you the option to place the result as text in your drawing. ;; Alternative: Quick total area with selection window

;; Helper function to check if object has area property (defun vlax-property-available-p (obj prop) (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-get-property (list obj prop)))) )

Change precision by modifying the prec variable (line ~15):

To change the output to square feet, divide the total area by 144. In the code above, look for this line: (setq totalArea (+ totalArea area)) Use code with caution. Change it to: (setq totalArea (+ totalArea (/ area 144.0))) Use code with caution. Converting Square Millimeters to Square Meters Display the result (princ (strcat "\nTotal Area of

Verify that the bottom of the dialog box states "TotalArea.lsp successfully loaded." , then close the window. Type into the command line to run the tool.

Here’s what my custom TLA (Total Area) routine does:

Filters these objects for those that possess area properties. Calculates the individual area for each object. Sums these areas together.