Try this.
Dirty and briefly tested but should works.
Chris
(defun c:add2sta (/ delta e sta)
(setq delta (getreal "\nValue to add to stations: "))
(while (setq e (car (nentsel)))
(if (setq sta (UnFormatStation (LM:gettextstring e)))
(progn
(setq sta (FormatStation (+ sta delta)))
(vla-put-TextString (vlax-ename->vla-object e) sta)
)
(alert "Wrong input format!")
)
)
)
; ================================================================================================= ;
; UnFormatStation (str / % DMZ km) ;
; Arguments: "###+###.##" ;
; (UnFormatStation "0+000,12") ;-> 0.0 ;
; (UnFormatStation "1+310,99") ;-> 1310.0 ;
(defun UnFormatStation (sta)
(atof (vl-string-subst "" "+" sta))
)
; ================================================================================================= ;
; FormatStation (num / % DMZ km) ;
; Arguments: num ;
; (FormatStation 0.12) ;-> "0+000,12" ;
; (FormatStation 1310.99);-> "1+310,99" ;
(defun FormatStation (num / % DMZ km)
(if (or (eq (type num) 'REAL) (eq (type num) 'INT))
(progn
(setq DMZ (getvar "DIMZIN"))
(setvar "DIMZIN" 0)
(setq % (rtos num 2 2))
(setvar "DIMZIN" DMZ)
(cond
((wcmatch % "#.##") (setq km (strcat "0+00" %)))
((wcmatch % "##.##") (setq km (strcat "0+0" %)))
((wcmatch % "###.##")
(setq km (strcat "0" "+" (substr % 1 6)))
)
((wcmatch % "####.##")
(setq km (strcat (substr % 1 1) "+" (substr % 2 6)))
)
((wcmatch % "#####.##")
(setq km (strcat (substr % 1 2) "+" (substr % 3 7)))
)
((wcmatch % "######.##")
(setq km (strcat (substr % 1 3) "+" (substr % 4 8)))
)
((wcmatch % "#######.##")
(setq km (strcat (substr % 1 4) "+" (substr % 5 9)))
)
(t %)
)
;(vl-string-translate "." "," km)
)
nil
)
)
; ================================================================================================= ;
;; Get Textstring - Lee Mac ;
;; Returns the text content of Text, MText, Multileaders, Dimensions & Attributes ;
(defun LM:gettextstring ( ent / enx itm str typ )
(setq enx (entget ent)
typ (cdr (assoc 0 enx))
)
(cond
( (wcmatch typ "TEXT,*DIMENSION")
(cdr (assoc 1 (reverse enx)))
)
( (and (= "MULTILEADER" typ)
(= acmtextcontent (cdr (assoc 172 (reverse enx))))
)
(cdr (assoc 304 enx))
)
( (wcmatch typ "ATTRIB,MTEXT")
(setq str (cdr (assoc 1 (reverse enx))))
(while (setq itm (assoc 3 enx))
(setq str (strcat (cdr itm) str)
enx (cdr (member itm enx))
)
)
str
)
)
)
Chris