这是一个简单的任务,但我现在没有时间拿起文本检查,如果“XX”存在使用wcmatch然后读取字符串到XX添加数字。
找到一些时间。
- ; replace XX with a number
- ; By Alan H jan 2016
- (defun c:add01 ( / obj ans x newstr)
- (setq x (getint "\nEnter start number press <Cr> to exit "))
- (while (/= (setq obj (vlax-ename->vla-object(car (entsel "\nPick text")))) nil) ; no errork check for text
- ; if less than 10 01-09 10+
- (if (< x 10.0)
- (setq newstr (strcat "0" (rtos x 2 0)))
- (setq newstr (rtos x 2 0))
- )
- (setq txtstr (vla-get-textstring obj)) ;return string val
- (if (> (setq pos (vl-string-search "XX" (strcase txtstr))) 1) ; return the position of XX
- (progn
- (setq num (strlen txtstr)) ; how many caharcters is string re abcdexxhjkl problem
- (setq ans (Strcat (substr txtstr 1 pos) newstr)) ; combine characters up to xx+01
- )
- )
- (vla-put-textstring obj ans) ; update text
- (setq x (+ x 1)) ; next number
- )
- (princ)
- )
|