Not sure I understand, but try this...
For 'Profile Pline' do not select the straight cyan polyline but the one with many vertices. (contrary to the previous proposition)
((lambda ( / ss ent lg obj ll ur ss_txt k n dxf_ent txt val pt)
(vl-load-com)
(setvar "CMDECHO" 0)
(princ "\nSelect Plan Alignment : ")
(while (not (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (8 . "C-ROAD-CNTR-N") (62 . 6) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
(setq
ent (ssname ss 0)
lg (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
obj (vlax-ename->vla-object ent)
)
(vla-GetBoundingBox obj 'll 'ur)
(setq
ll (safearray-value ll)
ur (safearray-value ur)
)
(command "_.zoom" "_w" ll ur)
(setq ss_txt (ssget "_C" ll ur '((0 . "MTEXT"))))
(cond
(ss_txt
(princ "\nSelect Profile Pline: ")
(while (not (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (62 . 4) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
(setq
ent (ssname ss 0)
k (/ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) lg)
)
(repeat (setq n (sslength ss_txt))
(setq
dxf_ent (entget (ssname ss_txt (setq n (1- n))))
txt (vl-string-left-trim "PVI\nKM.=" (cdr (assoc 1 dxf_ent)))
val (atof (vl-string-subst "" "+" txt))
lg (* k val)
pt (vlax-curve-getPointAtDist ent lg)
)
(command "_.-insert" "Pick" "_none" pt "" "" "")
(command "._text" "_none" pt "" "90" (strcat "PVI=" txt))
)
)
)
(setvar "CMDECHO" 1)
(prin1)
))