Try this:
(defun c:vername (/ s vertex_pos L_v)
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(if (setq s (car (entsel "\nSelect Polyline ")))
(progn
(setq vertex_pos "out") ;;; "ins" for inside
(setq L_v (pl_coord s))
(num_v L_v)
)
)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ)
)
;*************************************************************************
(defun pl_coord (# / p_ m)
(setq p_ (if (vlax-curve-IsClosed #)
(fix (vlax-curve-getEndParam #))
(1+ (fix (vlax-curve-getEndParam #)))
)
)
(while (/= 0 p_)
(setq m (cons (vlax-curve-getPointAtParam # (setq p_ (1- p_))) m))
)
)
;*************************************************************************
; Numera i vertici della polilinea
(defun num_v ( :lst / _a_ :pt dT nv)
(setq dT (* (getvar 'textsize) 1.1)) ;distanza del testo dal vertice
(if (or
(and (LM:ListClockwise-p :lst) (= vertex_pos "out"))
(and (null (LM:ListClockwise-p :lst)) (= vertex_pos "ins"))
)
(setq dT (- dT))
)
(setq nv 0)
(mapcar
(function
(lambda (a b c)
(setq _a_ (/ (+ (angle b c) (angle b a)) 2))
(if (minusp (- (angle b c) (angle b a))) (setq _a_ (+ _a_ pi)))
(setq :pt (polar b _a_ dT))
(entmake
(list
(cons 0 "TEXT")
(cons 7 (getvar 'textstyle))
(cons 10 :pt )
(cons 11 :pt )
(cons 40 (getvar 'textsize))
(cons 72 1)
(cons 73 2)
(cons 1 (itoa (setq nv (1+ nv))))
)
)
)
)
(cons (last :lst) :lst) :lst (append (cdr :lst) (list (car :lst)))
)
)
;*************************************************************************
;; List Clockwise-p - Lee Mac
;; Returns T if the point list is clockwise oriented
(defun LM:ListClockwise-p ( lst )
(minusp
(apply '+
(mapcar
(function
(lambda ( a b )
(- (* (car b) (cadr a)) (* (car a) (cadr b)))
)
)
lst (cons (last lst) lst)
)
)
)
)
;*************************************************************************
(vl-load-com)
;*************************************************************************