Give this a whirl. I assume from your wording you're talking 3d polylines not 2d or lwpoly's. It uses the leader command so arrow style and text font and size are controlled by the active dimstyle. If you use this on non 3d poly's the footage wont be right and it'll probably crash. let me know if you are needing this to work on both 3d and 2d or lwpoly's and can make it work.
Code:
(vl-load-com)
;this only works as intended on 3d polys, 2d polys give weird results
(defun c:foo ( / en lst tmp dist str1 str2 pt1 pt2)
;change "foo" to whatever command work for you
(while (not (setq en (ssname (ssget "_+.:E:S" '((0 . "POLYLINE"))) 0))))
(setq lst (getcoords en)
en (vlax-ename->vla-object en)
tmp (list (list (car lst) (cadr lst)))
lst (cdddr lst))
(repeat (/ (length lst) 3)
(setq tmp (append tmp (list (list (car lst) (cadr lst))))
lst (cdddr lst))
);end repeat
(setq lst tmp dist 0.0)
(repeat (- (length lst) 1)
(setq dist (+ dist (distance (car lst) (cadr lst)))
lst (cdr lst))
);end repeat
(setq mat (vlax-get en 'Material)
str1 (strcat "Horizontal Distance = " (rtos dist 2 0)) str2 (strcat "Material = " mat)
pt1 (getpoint "\nPick point for beginning of leader")
pt2 (getpoint "\npick point for end of leader"))
(command "_LEADER" pt1 pt2 "" str1 str2 "")
(princ)
);end defun
;I didnt write this function but don't know whom to give credit, sorry
(defun getcoords (ent)
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property
(vlax-ename->vla-object ent)
"Coordinates"
)
)
)
)
edit: cleaned code a little, if I knew what units you were measuring in I could add that to the label.