Could a fresh eyes check this subroutine why stop working in this part
(command "MASSPROP" obj "" "Y" wPath)
(defun C:CEN ( / doc index obj objects objlay objlist objtype )
(vl-load-com)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(LM:startundo doc)
;(setq obj (getpoint "Pick inside closed area"))
(setq objects (ssget '((-4 . "<OR")(0 . "LWPOLYLINE")(0 . "REGION")(-4 . "OR>")))
obj (ssname objects 0))
(while obj
(setq objlist (entget obj))
(setq objtype (cdr (assoc 0 objlist)))
(setq objlay (cdr (assoc 8 objlist)))
(cond
((and (= objtype "LWPOLYLINE") (= (cdr (assoc 70 objlist)) 1)) (command "REGION" obj "") (setq obj (entlast)) (get_centroid_point))
((= objtype "REGION") (get_centroid_point)))
(setq index (+ index 1)
obj (ssname objects index))
)
(LM:endundo doc)
(princ)
(princ "\n q_|_|| _\\|| q_|| _\\| ")
(princ "\n Type CEN to invoke the lisp")
)
(defun get_centroid_point (/ wpath open-a data vlen X-value Y-value c-point objtype ss )
(setq fd (getvar "filedia")) (setvar "FILEDIA" 0)
(setq cd (getvar "CMDECHO")) (setvar "CMDECHO" 0)
(command "LAYER" "set" objlay "")
(setq wPath nil)
(if (setq wPath (findfile "ACAD.PAT"))
(progn
(setq wPath (vl-filename-directory wPath))
(or (eq "\\" (substr wPath (strlen wPath)))
(setq wPath (strcat wPath "\\data")))))
(command "MASSPROP" obj "" "Y" wPath)
(setq datafile (strcat wPath ".mpr"))
(setq open-a (open datafile) "r")
(setq data "" )
(while (not (wcmatch data "Centroid:*"))
(setq data (read-line open-a))
)
(setq vlen (- (strlen data) 26)
X-value (atof (substr data 26 vlen))
Y-value (atof (substr (read-line open-a) 26 vlen))
c-point (list X-value Y-value)
)
(close open-a)
(if (= objtype "LWPOLYLINE")
(progn
(command "EXPLODE" obj)
(setq ss (ssget "p")
obj (ssname ss 0))
(command "PEDIT" obj "Y" "Join" ss "" "")
)
)
(command "POINT" c-point)
(setvar "FILEDIA" fd)
(setvar "CMDECHO" cd)
(princ)
)
;Error
(defun *error* ( msg )
(if val (mapcar 'setvar var val))
(if doc (LM:endundo doc))
(if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
(princ (strcat "\nError: " msg))) (princ))
(defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc))
(defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc)))