Hi,
Give this a shot and let me know.
(defun c:cnt ( / nxt pnt lst obj reg cen)
;;--------------------------------------------;;
;; Tharwat - Date: 08.12.2018 ;;
;; Print Centriod point from picked points. ;;
;;--------------------------------------------;;
(cond ((= 4 (logand 4 (cdr (assoc 70 (entget (tblobjname "LAYER" (getvar 'CLAYER))))))) (alert "Current layer is locked<!>"))
((and (setq nxt " ")
(while (setq pnt (getpoint (strcat "\nSpecify" nxt "point : ")))
(setq lst (cons pnt lst)
nxt " Next ")
)
lst
(setq obj (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length lst)) '(70 . 1))
(mapcar (function (lambda (p) (cons 10 p))) lst))))
)
(cond ((vl-catch-all-error-p (setq reg (vl-catch-all-apply 'vlax-invoke (list (vla-get-block (vla-get-activelayout (vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
'Addregion
(list (vlax-ename->vla-object obj))
)
)))
(alert "Error. Can't create the region <!>"))
(t (setq reg (car reg)
cen (vlax-get reg 'Centroid))
(alert (strcat "Centriod = " (vl-princ-to-string cen)))
(print cen)
(vla-delete reg))
))
)
(and obj (entdel obj))
(princ)
) (vl-load-com)
(princ "\nType CNT to start.")