Total Area Autocad Lisp →

LISP (LISt Processing) is a programming language embedded in AutoCAD since version 2.1. It allows you to automate repetitive tasks. A "Total Area LISP" is a script that:

Some advanced routines can even write the total to a text file, insert a multiline text object with the sum, or export a schedule.


(setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE"))))

Try the code above. Modify the unit outputs for your industry. Add a line that writes the total to a text file. Or make it color the selected objects green so you know what was counted.

What’s your one small LISP that saves you the most time? Share in the comments – I’m always looking for the next workflow hack. total area autocad lisp


Happy measuring – and may your polylines always be closed.

Introduction

AutoCAD provides various tools for calculating areas, but sometimes you need to calculate the total area of multiple objects. This can be achieved using AutoLISP, a programming language used for automating tasks in AutoCAD. In this guide, we will create a Lisp routine to calculate the total area of multiple objects.

Prerequisites

Step 1: Create a new Lisp file

Step 2: Define the Lisp function

In the total_area.lsp file, add the following code:

(defun total-area ()
  (setq total 0)
  (setq ss (ssget "_:L"))
  (setq count (sslength ss))
  (repeat count
    (setq ent (ssname ss 0))
    (setq area (vla-get-Area (vlax-ename->vla-object ent)))
    (setq total (+ total area))
    (ssdel ent ss)
  )
  (princ "Total Area: ")
  (princ total)
  (princ "\n")
)

Let's break down the code:

Step 3: Load the Lisp file

Step 4: Run the Lisp function

Tips and Variations

By following these steps, you can create a Lisp routine to calculate the total area of multiple objects in AutoCAD. LISP (LISt Processing) is a programming language embedded