RecipesCount and measure
How do I get the area of every closed polyline in an AutoCAD drawing?
Type "list the area of every closed polyline on layer A-AREA, in m²". cadssistant selects the closed polylines on that layer, reads each one's area with vlax-curve-getArea in one AutoLISP pass, converts from drawing units using a factor it states, and replies with a table of handle and area plus the total. Nothing is modified. Say "write the area inside each outline" and it adds a text entity at each centroid in a second step.
Checked 2026-10-30
list the area of every closed polyline on layer A-AREA, in m²
Paste it into the palette, or pick it from the recipes inside the chat.
What cadssistant does
- Selects the closed LWPOLYLINEs on the layer: (0 . "LWPOLYLINE") with the closed bit of group 70 tested through a (-4 . "&") filter.
- Reads each area with vlax-curve-getArea in one AutoLISP pass and converts it with the factor the drawing's units imply (1 unit = 1 mm gives ÷ 1 000 000), stating the factor in the reply.
- Replies with a table of handle and area, plus the total.
The same task in AutoLISP
(progn
(vl-load-com)
(setq ss (ssget "_X" '((0 . "LWPOLYLINE") (8 . "A-AREA") (-4 . "&") (70 . 1)))
i 0 rows nil)
(if ss
(repeat (sslength ss)
(setq e (ssname ss i) i (1+ i))
(setq rows (cons (list (cdr (assoc 5 (entget e))) (/ (vlax-curve-getArea e) 1e6)) rows))))
rows)Handle and area in m² for a drawing in millimetres. Use 1e4 for centimetres, or drop the division for metres.
Good to know
- An outline drawn as separate lines isn't a closed polyline. Say "join the lines on A-AREA into polylines first" and it runs PEDIT with Join before measuring.
More in count and measure
Command: CADSSISTANT
Works in AutoCAD 2024 and newer on Windows. Free trial, no card, no API key.
Get cadssistant