Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify `Change text string' lsp routine to include attribute strings

14 REPLIES 14
Reply
Message 1 of 15
mbuk
495 Views, 14 Replies

Modify `Change text string' lsp routine to include attribute strings

Hi,

I have attached an old lisp routine called CHGTEXT.lsp.

This routine allows the user to select multiple occurances of text and to change text strings within the text.

I've added code to include Mtext as shown below:

(if (or (= "TEXT" ; Look for TEXT entity type (group 0)
(cdr (assoc 0 (setq e (entget (ssname p l))))))
(= "MTEXT" ; Look for MTEXT entity type (group 0)
(cdr (assoc 0 (setq e (entget (ssname p l))))))
);end or

It now seems to work to include Mtext.

What code would be needed to include visible attribute strings.

I realize the Find command does this, but this routine shows you exactly what has been selected.

Any improvements to the routine are always welcome.

Any help is always greatly appreciated.


Mark
14 REPLIES 14
Message 2 of 15
H.vanZeeland
in reply to: mbuk

Hi,

Try it with this


It can not used for dimensions

Cheers
Harrie
Message 3 of 15
RKLindner
in reply to: mbuk

I like yours (and T. Willey's) version. I added *LEADER to also get Multileaders in 2008

(0 . "*TEXT,ATTDEF,*LEADER")

seems to work.. so far.

Richard
Message 4 of 15
H.vanZeeland
in reply to: mbuk

Richard,

It bombs by a leader.
Better add MULTILEADER rather than *LEADER

Look at the attach modified version.

Cheers
Harrie
Message 5 of 15
mbuk
in reply to: mbuk

Hi Harrie,

Thanks. It works great.

I modified it so that it prompts the user to tell him what to do.
I also changed the order so that the user is asked first to select the text before he is asked to change the string. Is there a way we could replace the `select objects' prompt (from ssget ) to the prompt I have listed? (Select TextString etc...)

I also expanded the princ (at the end that tells the user the number of occurances) and changed it to an alert.
You will see it now alerts the user (instead of printing at the command line) as to the number of ocurrances of the old text that have been replaced with the new text. I noticed that it alerts the user before it actually changes the text.
Is there a way to have the textstrings change before the user is alerted?

Try it and let me know what you think?

Thanks

Mark

w
Message 6 of 15
mbuk
in reply to: mbuk

Harrie,

Would it be possible for comments to be put into the Gtxt1.lsp?. If you noticed in the original chgtext.lsp routine each line was commented so I was able to figure out what they were doing. I am not familiar with all of the Vlax commands and am still trying to see how Mapcar fits in.

Thanks

Mark
Message 7 of 15
H.vanZeeland
in reply to: mbuk

Mark,

Change it such as you wants itself.

There are many way's to changetext, it is personal what way.
The Find and replace from Autocad is the best way.


If a block contains many attributes
the result is not always well predictable.

Also the alert box is personal.

There is no error function (if it canceled)

There are maybe better routines for changetext.

I have comment the gTxt1.lsp (look at the attached file)
Hope this helps.

Cheers
Harrie
Message 8 of 15
mbuk
in reply to: mbuk

Hi Harrie,

I think you attached Gtxt (the original). If you could please send the gtxt1 with the comments it would be greatly appreciated.

Thanks

Mark
Message 9 of 15
H.vanZeeland
in reply to: mbuk

Mark,

Sorry for that

Harrie
Message 10 of 15
mbuk
in reply to: mbuk

Thanks Harrie,

Did you take a look at the alert code I added. I want the program to change the strings, and then alert the user. It doesn't do that right now.

Mark
Message 11 of 15
H.vanZeeland
in reply to: mbuk

Mark,

If you want the alert box only if strings then use the follow code

(if (> SelChanged 0)
(alert (strcat "Changed "(itoa SelChanged)" Ocurrances of Old TextString \""
OldStr "\"\t\n\nWith New TextString \"" NewStr "\"\t"))
(princ"\nNothing Changed.")
)

Cheers
Harrie
Message 12 of 15
mbuk
in reply to: mbuk

Harrie,

The Alert box is displayed but the strings do not change until you select the `OK' button in the alert box. I would like Alert box to be displayed only after you have seen the strings change on the screen.

Mark
Message 13 of 15
H.vanZeeland
in reply to: mbuk

Hi,

Try this

Cheers
Harrie
Message 14 of 15
mbuk
in reply to: mbuk

Harrie,

You're amazing! It works perfectly.

Thanks

Mark
Message 15 of 15
mbuk
in reply to: mbuk

Harrie,

I posted a topic called :

looking for a lisp routine to select block & count number of the blocks selected.'

The routine almost works. i am having trouble making a loop of a list. (agin this is to print an alert)

Would you please take a look?

Thanks

Mark

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost