Jump to content

Remove the space from a text


Sweety

Recommended Posts

A very great words .

 

I would keep them in mind all the time while asking for any help from anyone .

 

Thank you so much for your positive efforts with me.

 

Greatly appreciated Mr. Alanjt

Link to comment
Share on other sites

  • 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

A person is only as stupid as they allow themselves to be.

 

To realize one's own stupidity, without the inherent luxury of seeing one's self through a prism of wisdom, is a daunting task at best.

 

While I greatly value knowledge, it is wisdom that I seek.

Link to comment
Share on other sites

Are you saying stupid is as stupid does?
Six in one' date=' half a dozen in the other, Forrest.

 

A very great words .

 

I would keep them in mind all the time while asking for any help from anyone .

 

Thank you so much for your positive efforts with me.

 

Greatly appreciated Mr. Alanjt

Welcome. :)
Link to comment
Share on other sites

To realize one's own stupidity, without the inherent luxury of seeing one's self through a prism of wisdom, is a daunting task at best.

 

While I greatly value knowledge, it is wisdom that I seek.

Stupid is a relative term. Meaning, if a person doesn't put forth the effort, nothing will be accomplished. I understand that some just can't comprehend, but no one could if they didn't at least make an attempt.

Sticking feathers up your butt doesn't make you a chicken = scraping bits of code together doesn't make you a programmer.

Edited by alanjt
TYPO
Link to comment
Share on other sites

BTW, I really like the repeat from the string length idea, Lee.

 

Thanks Alan :)

 

However, why'd you worry with converting the string to an ascii character when (eq s " ") would have sufficed?

 

Because, I thought it'd be quicker than (substr s 1 1) :) Just taking advantage of the fact that:

 

(ascii "abc")  <==>  (ascii (substr "abc" 1 1))

Looking back on it now, the quickest thing would probably be set a variable to (substr s 1 1), test it, then concatenate it to the end of output 'o'. Oh well, I'm happy.

 

BTW thanks for making me look back at my sub, just realised I don't need the 'i' argument in the nospace sub - was going to go a different route when I wrote it. Code updated.

Link to comment
Share on other sites

Stupid is a relative term. Meaning, if a person doesn't put forth the effort, nothing will be accomplished. I understand that some just can't comprehend, but no one could if they didn't at least make an attempt.

Sticking feathers up your butt doesn't make you a chicken = scraping bits of code together doesn't make your a programmer.

 

Agreed... I was simply sharing what this stale fortune cookie on my desk said. I'm hungry. :P

Link to comment
Share on other sites

Thanks Alan :)

 

 

 

Because, I thought it'd be quicker than (substr s 1 1) :) Just taking advantage of the fact that:

 

(ascii "abc")  <==>  (ascii (substr "abc" 1 1))

Looking back on it now, the quickest thing would probably be set a variable to (substr s 1 1), test it, then concatenate it to the end of output 'o'. Oh well, I'm happy.

 

BTW thanks for making me look back at my sub, just realised I don't need the 'i' argument in the nospace sub - was going to go a different route when I wrote it. Code updated.

Interesting idea. However, I would have stored it as a variable. Any speed you gained from the ascii check (is faster), you lost when you used (substr s 1 1) to keep the string.

 

BTW, did you see my recursive submission?

Link to comment
Share on other sites

Interesting idea. However, I would have stored it as a variable. Any speed you gained from the ascii check (is faster), you lost when you used (substr s 1 1) to keep the string.

 

Exactly :)

 

BTW, did you see my recursive submission?

 

Yeah, nice one :) - although I suppose with recursion you sacrifice speed for elegance :)

Link to comment
Share on other sites

Exactly :)

 

 

 

Yeah, nice one :) - although I suppose with recursion you sacrifice speed for elegance :)

Yeah, sadly, that's the case for this situation, but as you said, it was for the sake of a Vanilla challenge. I'm sticking with the vl-remove way - much faster.
Link to comment
Share on other sites

FYI Mat, if you are going to edit entities as vla-objects, it's faster to use vla-get-activeselectionset than to step through the selectionset and convert to vla-objects.

 

Dually noted.

 

For kicks, here's another option (does the same thing), using Alan's suggestion:

 

(defun c:FOO  (/ ss s)
 (vl-load-com)
 (vla-startundomark
   (cond (*activeDoc*)
         ((setq *activeDoc*
                 (vla-get-activedocument (vlax-get-acad-object))))))
 (if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
   (progn
     (vlax-for x (setq ss (vla-get-activeselectionset *activeDoc*))
       (setq s (vla-get-textstring x))
        (while (vl-string-search " " s)
          (setq s (vl-string-subst "" " " s)))
        (vla-put-textstring x s))
     (vla-delete ss)))
 (vla-endundomark *activeDoc*)
 (princ))

Link to comment
Share on other sites

 
(defun c:rt (/ ds_txt str pst )
   (setq ds_txt (entget (car (entsel "\nSeect Text: ")))
  str (cdr (assoc 1 ds_txt)))

 (while (setq pst (vl-string-search " " str))
    (setq str (strcat (substr str 1 pst)(substr str (+ pst 2))))
   )
   (entmod (subst (cons 1 str)(assoc 1 ds_txt) ds_txt))
 )

 

Mind if i join in... without looking at the previous posts

this is how i code it.. i'm trying to create one without vl like Lee Mac.. i'm getting there.. :).. making it short as possible..

Link to comment
Share on other sites

Look into vl-string-subst pBe :)

 

I think if you are looking for both speed and concision, the vl-remove method is the way to go - also, this will work on Text, MText, Attributes, and MLeaders:

 

(defun c:test ( / e ) (vl-load-com)

 (while (setq e (car (nentsel)))
   (if (vlax-property-available-p (setq o (vlax-ename->vla-object e)) 'TextString)
     (vla-put-TextString o (vl-list->string (vl-remove 32 (vl-string->list (vla-get-TextString o)))))
   )
 )

 (princ)
)

Link to comment
Share on other sites

Look into vl-string-subst pBe :)

 

I think if you are looking for both speed and concision, the vl-remove method is the way to go - also, this will work on Text, MText, Attributes, and MLeaders:

 

 

I tried it, works like a charm.. its like 4 in1 function :)

 

Thanks to you guys my programing skills have improved a lot

Link to comment
Share on other sites

I tried it, works like a charm.. its like 4 in1 function :)

 

Thanks to you guys my programing skills have improved a lot

 

You're very welcome - it was pretty much exactly the same for us guys - we mostly learnt what we know from these forums also...

Link to comment
Share on other sites

Look into vl-string-subst pBe :)

 

I think if you are looking for both speed and concision, the vl-remove method is the way to go - also, this will work on Text, MText, Attributes, and MLeaders:

 

(defun c:test ( / e ) (vl-load-com)
 (while (setq e (car (nentsel)))
   (if (vlax-property-available-p (setq o (vlax-ename->vla-object e)) 'TextString)
     (vla-put-TextString o (vl-list->string ([b][color="red"]vl-remove 32[/color][/b] (vl-string->list (vla-get-TextString o)))))
   )  )
 (princ)
)

 

Hello Lee,

 

What is the number 32 indicates to into your routine (is it the free space indication) ?

 

Thanks

Link to comment
Share on other sites

What is the number 32 indicates to into your routine (is it the free space indication) ?

 

Hi Michaels,

 

Read the VLIDE Help Docs on the vl-string->list function, then you tell me :)

Link to comment
Share on other sites

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...