Jump to content

Recommended Posts

Posted (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"? :facepalm: Thanks.

 

Ooopsie! I forgot I changed the command name and it was calling the old code up. My bad. It works great! :notworthy:

Edited by ryoerger
I forgot I changed the command name and it was calling the old code up.
  • Replies 62
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    15

  • alanjt

    14

  • Michaels

    8

  • Sweety

    8

Top Posters In This Topic

Posted Images

Posted

Works fine here mate.

 

Give me a real sample.

 

EDIT: I see you edited your post.

 

Glad it works for you.

 

Cheers.

Posted

Yes it does. Refer to my previously modified post. Thanks again pBe!:D

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...