Change 2 first characters fo Mtext

Change 2 first characters fo Mtext

Anonymous
Not applicable
971 Views
6 Replies
Message 1 of 7

Change 2 first characters fo Mtext

Anonymous
Not applicable

Hi masters!! 

 

As the title says i want to change the 2 first characters of a Mtext.

The selection of those Mtexts will be:

 

(setq Mset (ssget "X" '((0 . "*text")(1 . "*c/*"))))

 

I really dont know how to continue.

 

Thanks in advance!

0 Likes
Accepted solutions (1)
972 Views
6 Replies
Replies (6)
Message 2 of 7

dlanorh
Advisor
Advisor

Perhaps by telling us how you want to change them?

I am not one of the robots you're looking for

0 Likes
Message 3 of 7

Anonymous
Not applicable

I want to change the 2 first characters for "1"

0 Likes
Message 4 of 7

dlanorh
Advisor
Advisor
Accepted solution
  (setq Mset (ssget "X" '((0 . "*text")(1 . "*c/*"))))
  (cond (Mset
          (repeat (setq cnt (sslength Mset))
            (setq ent (ssname Mset (setq cnt (1- cnt)))
                  elst (entget ent)
                  txt (strcat "1" (substr (cdr (assoc 1 elst)) 3))
            )
            (entmod (subst (cons 1 txt) (assoc 1 elst) elst))
          )
        )
  )

I am not one of the robots you're looking for

Message 5 of 7

Anonymous
Not applicable

That worked!

 

Thank you so much!

0 Likes
Message 6 of 7

dlanorh
Advisor
Advisor

You have a small error in your ssget statement.

 

(setq Mset (ssget "X" '((0 . "*text")(1 . "*c/*"))))

 

this will select text with "c/" anywhere in the text string, but will still change the first two characters. To select "c/" only at the start change your ssget to

 

(setq Mset (ssget "X" '((0 . "*text")(1 . "c/*"))))

 

 

I am not one of the robots you're looking for

0 Likes
Message 7 of 7

Anonymous
Not applicable

Its ok. First 2 characters are 2 numbers and it follows with c/. And i want to change those characters for 1.

Thanks for your help!!

0 Likes