Here's a modified version that checks the Lunits sysvar and reacts accordingly. Not intended for use in metric drawings at this time.
Code:
;; =================================================
;; 2002 By Luis Esquivel
;; put the area in sq-ft of selected closed areas...
;; modified 11/22/03 by Jeff Mishler to allow use within
;; PS Viewport and to accept a Polyline that was created
;; by selecting the startpoint as the endpoint, technically
;; it is closed but the closed property isn't set.
;;
;; Command: PUTAREA
;;;(addtext <string> <point> <real>)
(defun addtext (textstring insertionpoint height / aa)
(vl-load-com)
(setq aa (vla-get-activedocument (vlax-get-acad-object)))
(vla-addtext
(if (= 1 (vla-get-activespace aa))
(vla-get-modelspace aa)
(if (= (vla-get-mspace aa) :vlax-true)
(vla-get-modelspace aa)
(vla-get-paperspace aa)
)
)
textstring
(vlax-3d-point insertionpoint)
height)
)
(defun add-comma (txt / strl cont1 lth cont txt1)
(setq strl (strlen txt)
cont1 1
txt1 "")
(while (and (/= (substr txt cont1 1) ".") (<= cont1 strl))
(setq cont1 (1+ cont1)))
(setq lth (1- cont1)
cont1 1
cont (1- lth))
(if (> lth 3)
(progn
(while (< cont1 lth)
(setq let (substr txt cont1 1)
txt1 (strcat txt1 let))
(if (and (zerop (rem cont 3)) (eq (type (read let)) 'INT))
(setq txt1 (strcat txt1 ",")))
(setq cont (1- cont)
cont1 (1+ cont1)))
(while (<= cont1 strl)
(setq txt1 (strcat txt1 (substr txt cont1 1))
cont1 (1+ cont1)))
txt1)
txt))
(defun get-last-coord (obj / COORDS LAST_COORD)
(setq coords (vla-get-coordinates obj)
coords (vlax-safearray->list (vlax-variant-value coords))
coords (reverse coords)
last_coord (list (cadr coords)(car coords)
)
)
last_coord
)
(defun C:PUTAREA (/ ent vla_obj pt objname vla_text aa lunit)
(while (setq ent (entsel "\nSelect closed object: "))
(setq vla_obj (vlax-ename->vla-object (car ent))
objname (vla-get-objectname vla_obj))
(if
(vlax-property-available-p vla_obj 'area)
(progn
(if
(or
(= "AcDbCircle" objname)
(and (wcmatch (vla-get-objectname vla_obj) "*Polyline")
(or (= :vlax-true (vla-get-closed vla_obj))
(equal (vlax-safearray->list
(vlax-variant-value
(vla-get-coordinate vla_obj '0)))
(get-last-coord vla_obj)
0.001)
)
)
)
(progn
(if (setq pt (getpoint "\nPick text placement: "))
(progn
(setq lunit (getvar "lunits"))
(setq vla_text
(addtext
(strcat
(add-comma
(rtos
(if (or (= lunit 3)
(= lunit 4)
)
(/ (vla-get-area vla_obj) 144)
(vla-get-area vla_obj)
)
2
0))
" S.F.")
pt
(getvar "textsize")))
;; alignment to left
(vla-put-alignment vla_text acAlignmentCenter)
(vla-put-textalignmentpoint
vla_text
(vlax-3d-point pt))
;; use current textstyle
(vla-put-stylename
vla_text
(vla-get-name
(vla-get-activetextstyle
(setq aa (vla-get-activedocument
(vlax-get-acad-object)))))))))
(prompt "\nNot a closed object. ")
))))
(princ))
(princ)