I had this from Lee, but usually always go way counter-clockwise and only select the polyline, not the point. 
  
;; Polyline Vertex Exporter ~ by Lee McDonnell ~ 26.11.2009 
(defun c:pExp2 (/ ss tmp i j ent tot dis pt) 
(vl-load-com) 
(if (and (setq ss (ssget '((0 . "*POLYLINE")))) 
(setq tmp (getfiled "Output File" (cond (*load) ("")) "txt;csv" 9))) 
(progn 
(setq *load tmp tmp (open tmp "a") i -1) 
(write-line "X,Y,Layer" tmp) 
(while (setq ent (ssname ss (setq i (1+ i)))) 
(setq tot 0. j (1- (vlax-curve-getStartParam ent))) 
(while ( 
(setq pt (mapcar 'rtos (vlax-curve-getPointatParam ent j)))  
(write-line 
(strcat (car pt) (chr 44) (cadr pt) (chr 44) (vla-get-layer (vlax-ename->vla-object ent))) 
tmp)) 
(write-line "" tmp)) 
(close tmp))) 
(princ)) 
  
THX for any tips.