ryoerger Posted June 27, 2012 Posted June 27, 2012 (edited) Are you sure the space at the end remains? QUOTE] Good catch. The space at the right of the text string is removed by your code post. I only need to lose the the space preceeding the text string. Code: (defun c:removespcs ( / e str l p) (vl-load-com) (while (setq e (car (nentsel))) (if (and (vlax-property-available-p (setq o (vlax-ename->vla-object e)) 'TextString) (setq str (vla-get-TextString o)) (vl-string-search " " str)) (progn (while (setq p (vl-string-position 32 str nil t)) (setq l (cons (strcat " " (substr str (+ 2 p))) l) str (substr str 1 p))) (setq str (vl-string-left-trim " " (strcat str (apply 'strcat (vl-remove-if '(lambda (j)(eq j " ")) l)))) l nil) (vla-put-textstring o str) ) ) ) (princ) ) The addition of this code: (vl-string-left-trim " " Did not accomplish this either... is that why you said "Hang on"? Thanks. Ooopsie! I forgot I changed the command name and it was calling the old code up. My bad. It works great! Edited June 27, 2012 by ryoerger I forgot I changed the command name and it was calling the old code up. Quote
pBe Posted June 27, 2012 Posted June 27, 2012 Works fine here mate. Give me a real sample. EDIT: I see you edited your post. Glad it works for you. Cheers. Quote
ryoerger Posted June 27, 2012 Posted June 27, 2012 Yes it does. Refer to my previously modified post. Thanks again pBe! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.