好啊我喝了咖啡,这似乎奏效了
- (defun c:incsta (/ int isreal lst newstr pos ss string)
- (vl-load-com)
- (if (setq ss (ssget ":L" '((0 . "text") (1 . "*+*")))
- int (getint "\nEnter increment amount: ")
- )
- (foreach str (mapcar 'vlax-ename->vla-object
- (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
- )
- (setq string (vla-get-textstring str)
- lst (vl-string->list string)
- newstr (rtos (+ int (atof (apply 'strcat (mapcar 'chr (vl-remove 43 lst)))))
- 2
- (if (setq isreal (vl-string-position 46 string))
- (strlen (substr string (+ 2 isreal)))
- 0
- )
- )
- pos (abs
- (+ (vl-string-position 43 string) (- (1+ (strlen newstr)) (strlen string)))
- )
- newstr (strcat (substr newstr 1 pos) "+" (substr newstr (1+ pos)))
- newstr (strcat (if (wcmatch newstr "+*")
- "0"
- ""
- )
- newstr
- )
- )
- (vla-put-textstring str newstr)
- )
- )
- (princ)
- )
|