In addition to @Kent1Cooper solutions, I would also recommend the following:
Consider using a selection filter to only select Plines that are closed using this code:
;; CLICK ON CLOSED POLYLINE
(while (not ep)
(princ"\nPick a Closed Polyline...")
(setq ep (ssget "_+.:E:S" '((0 . "POLYLINE,LWPOLYLINE") (-4 . "&") (70 . 1)))) ;; restrict selection
)
Then when the desired entity is selected use the following code to get the entity and entity data:
(if ep ; after valid entity is selected
(progn ; then do the following
;; get Entity name
(setq en (ssname ep 0))
;; get Entity data
(setq ent (entget en))
Instead of using Area command and system variable to get the Pline's area, use a Field so that whenever the Pline changes the area string will update automatically:
;;;---load vl functions
(if(not(car (atoms-family 1 '("vl-load-com"))))(vl-load-com))
; Get-ObjectIDx64 given object return object ID
(defun Get-ObjectIDx64 (obj / util)
(setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))))
(if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj)))
(if (= (type obj) 'VLA-OBJECT)
(if (> (vl-string-search "x64" (getvar "platform")) 0)
(vlax-invoke-method util "GetObjectIdString" obj :vlax-False)
(rtos (vla-get-objectid obj) 2 0)
)
)
) ; defun Get-ObjectIDx64
;; force fieldeval to be 31 so Fields will update after regen, save, plot and etc
(if(/= 31 (getvar"fieldeval"))(setvar"fieldeval"31))
;; Convert Area to Square Feet vs Square Inch
;; (princ "\nTotal Area = ")
;; (command "._Area" "_O" en)
;; (setq AreaString (getvar "area"))
;; Use Fields to link pline area
;; for square feet use this
; (setq AreaString (strcat (rtos (/ AreaString (* 12 12)) 2 2) " FT" (chr 178))) ;; Limit significant digits to max. 2
(setq AreaString
(strcat
"%<\\AcObjProp.16.2 Object (%<\\_ObjId "
(Get-ObjectIDx64 (vlax-ename->vla-object en))
">%).Area \\f \"%lu2%pr2%ps[, Ft"
(chr 178)
"]%ct8[0.0069444444444444]%th44\">%"
)
)
;; for square inch use this
; (setq AreaString (strcat (rtos AreaString 2 2) " Inch" (chr 178))) ;; Limit significant digits to max. 2
(setq AreaString
(strcat
"%<\\AcObjProp.16.2 Object (%<\\_ObjId "
(Get-ObjectIDx64 (vlax-ename->vla-object en))
">%).Area \\f \"%lu2%pr2%ps[, Inch"
(chr 178)
"]%th44\">%"
)
)
For the zone tag placement, consider initially using the current view center point for Insert and then end with the Move command so you can actually see the zone tag on the screen:
(setq ip (getvar"viewctr"))
;; INSERTS ZONE TAG BLOCK
(command "_.Insert" "ZONE AREA TAG" ip 1 1 0 AreaString ZoneName) ;; Inserts a fitting at the specified scale and location.
(setq dragmode (getvar "dragmode")) ; save current dragmode setting
(setvar "dragmode" 2) ; set to 2
;; Reposition inserted block
(princ "\nPlace the Zone Tag: ")
(command "_.Move" "_L" "" ip pause)
(setvar "dragmode" dragmode) ; restore setting