@bcddss Try this:
Works with straight segment polylines. Area calculated using cross method.
If you need rounded coordinates uncomment i.e. remove leftmost ; from lines at the bottom.
;(princ "\nRounded coordinates > ") ;uncomment to see poly coordinates
;(princ lst) ;uncomment to see poly coordinates
(defun c:a3dec ( / pick_poly take take2 pointlist2d eo lst i suma sumb)
(vl-load-com)
;Author: hak_vz
;Saturday, March 5, 2022
;https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556
;Posted at
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/area-from-polyline-round-up/td-p/10984310
;Calculates area of closed polyline with coordinates rounded to 3 decimal places
(defun pick_poly (msg)
(setq e (car(entsel msg)))
(if (and (not e) (= (getvar 'Errno) 7)) (pick_poly msg) e)
)
(defun take (amount lst / ret)(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))
(defun take2 (lst) (take 2 lst))
(defun pointlist2d (lst / ret) (while lst (setq ret (cons (take 2 lst) ret) lst (cddr lst))) (reverse ret))
(setq eo (vlax-ename->vla-object (pick_poly "\nSelect polyline >")))
(cond
((= (vla-get-Objectname eo) "AcDbPolyline")
(setq lst (pointlist2d (mapcar '(lambda (x) (atof(rtos x 2 3))) (vlax-get eo 'Coordinates))))
(setq lst (append lst (list (car lst))))
(setq i -1)
(setq lst (append lst (list (car lst))))
(setq i -1 suma 0 sumb 0)
(while (< (setq i (1+ i)) (-(length lst) 1))
(setq suma (+ suma (* (car (nth i lst))(cadr (nth (+ i 1) lst)))))
(setq sumb (+ sumb (* (cadr (nth i lst))(car (nth (+ i 1) lst)))))
)
;(princ "\nRounded coordinates > ") ;uncomment to see poly coordinates
;(princ lst) ;uncomment to see poly coordinates
(princ (strcat "\nArea = " (rtos (abs(* 0.5 (- suma sumb))) 2 2)))
)
)
(princ)
)
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.