vl-string-translate
I'm trying to use thevl-string-translate function to replace a character within a text string thus:
(defun c:test ( / a b )(setq a (entget(car(entsel)))) (setq b(cdr(assoc 1 a))) (princ (vl-string-translate "NO." "No." b)) )
But after many experiments in the Console all I keep getting is BoILER No. 2 instead of BOILER No. 2.
Anyone know how to make
vl-string-translate only find an "o" when preceded by a "N" ? Try vl-string-subst
(defun c:test ( / a b )(setq a (entget(car(entsel)))) (setq b(cdr(assoc 1 a))) (princ (vl-string-subst "No." "NO." b)) )
Henrique Henrique, thank you very much. I've not seen that one before.
All I've got to do is put in an entmod now
(defun c:test ( / a b ntext)(setq a (entget(car(entsel)))) (setq b(cdr(assoc 1 a))) (setq ntext (vl-string-subst "No." "NO." b)) (entmod(subst (cons 1 ntext) (assoc 1 a) a)) )(vl-load-com) You're welcome!
Glad I could help
Henrique If your using Vl why not all, saves remembering dxf codes
(defun c:test ( / a b ntext)(setq obj (vlax-ename->vla-object (car(entsel))))(setq b (vla-get-textstring obj))(setq ntext (vl-string-subst "No." "NO." b))(vla-put-textstring obj ntext))(vl-load-com)
Good plan BIGAL. Thank you v much, I shall give it a try when I get into work soon.
I've only just (this month) entered the realm of VL type functions, & this is my first attempt. As you can see from the poorly chosen VL from the subject, I'm somewhat inexperienced, although I've copied other folks VL code before.
页:
[1]