Can lisp be used to auto replace text like Word?

Can lisp be used to auto replace text like Word?

h_s_walker
Mentor Mentor
1,372 Views
15 Replies
Message 1 of 16

Can lisp be used to auto replace text like Word?

h_s_walker
Mentor
Mentor

e.g. in Word you could type "LSC" followed by a space and the "LSC" would immediately change to light surface corrosion.

This would need to work in LT2025 as that is all I have

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
1,373 Views
15 Replies
Replies (15)
Message 2 of 16

cadffm
Consultant
Consultant

Hi,

 

not "on the fly". You can use/create a Tool to change "LSC" to "light surface corrosion",

as you can do it by FIND manually.

Some "find&replace" or "translation" tools using lists as well, so you have a standard translation list

to replace some words.

 

But all these tools working "outside" of text-editing situations, not in realtime by type-in your text value.

Sebastian

Message 3 of 16

DGCSCAD
Collaborator
Collaborator

Maybe set that up in a "Spell" custom dictionary. I haven't played around with it, but it seems like the way to go.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 4 of 16

h_s_walker
Mentor
Mentor

@DGCSCAD I don't think that will work, because it's three letters which should be replaced with three separate words, and the custom dictionary won't recognize three separate words as a replacement for one "spelling mistake"

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 5 of 16

pendean
Community Legend
Community Legend

Mtext 'autocomplete' ability needs to come from Autodesk Programmers, ask for it here

 here https://www.autodesk.com/company/contact-us/product-feedback 

 

0 Likes
Message 6 of 16

h_s_walker
Mentor
Mentor

@pendean I already asked for that ages ago

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 7 of 16

pendean
Community Legend
Community Legend

@h_s_walker wrote:

@pendean I already asked for that ages ago


Keep asking: encourage others to do it too and often. Remember, yours (and 100s like it) have to stand out to get noticed, sadly one-and-done is never going to cut it.

0 Likes
Message 8 of 16

cadffm
Consultant
Consultant

Or you create your own create/edit Text tool,

so you write the content in your lisp and after you are ready, the tool create/edit the text-object.

This is possible.

Sebastian

0 Likes
Message 9 of 16

DGCSCAD
Collaborator
Collaborator

Here's a sub function (courtesy of komondormrex) that changes a supplied text string to red, but you could alter it to change the text string. I use this in a tool that either creates a new mtext object or updates selected mtext's, so it's not exactly global on-the-fly when creating mtext, but used as a specific function:

 

 

(defun DS2red (/ mtext mtext_string)
	(setq mtext ent;(car (entsel "\Pick mtext: "))
		  mtext_string (vla-get-textstring (vlax-ename->vla-object mtext))
		  sub_color 1;(getint "\nEnter color for submtext: ")
	)
	(vla-put-textstring (vlax-ename->vla-object mtext) 
						(acet-str-replace "\\((*dip solder+)*\\)" 
										 (strcat "{\\C" (itoa sub_color) ";\\1}") 
										 mtext_string t t
						)
	)
)

 

 

Also, I should mention that it uses Express Tools (acet-str-replace).

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 10 of 16

h_s_walker
Mentor
Mentor

@DGCSCAD I only have LT so have no access to Express tools

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 11 of 16

DGCSCAD
Collaborator
Collaborator

I somehow failed to remember that after reading it. lol 

AutoCad 2018 (full)
Win 11 Pro
Message 12 of 16

ec-cad
Collaborator
Collaborator

Doesn't look like what you are looking for, but here's a Lisp that will search-replace strings in 

Text / Mtext and Attributes within Blocks (does not 'do' text that is part of a Block).

You drag / drop it into a Acad session, type SREP to call up the function. It allows for selecting

either 'All' or 'C' for crossing, or 'W' for window.

 

ECCAD

0 Likes
Message 13 of 16

Sea-Haven
Mentor
Mentor

Just an idea bit like auto correct you could invoke a new pseudo Mtext command so enter your mtext as normal with the short cuts "lsc" etc, then when you exit the mtext it checks the words inside to see if they match your short hand, looking for multiple words. You would make a list of short & Full words could be a text file that is read once per session. Lee-mac has a program that can be used to separate all words via the space into a list. You can check pretty quick is a word in a list via Member function. 

 

How many words are you talking about ?

Message 14 of 16

h_s_walker
Mentor
Mentor

@Sea-Haven I'm not sure how many words it would be, but it would need to be added to.

We add a load of repetitive text to drawings, and it would be great if we could just type the letters and it would replace them

e.g. The corrosion text will have light, moderate, heavy, severe or a combination of those

 

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 15 of 16

Sea-Haven
Mentor
Mentor

If you make a text file with old,new then can do something along idea of method I suggested. Who knows when auto suggest will be added. If happy with that idea post a csv file. 

 

lsc,light surface corrosion

hsc,heavy surface corrosion

0 Likes
Message 16 of 16

Jonathan3891
Advisor
Advisor

There is an awesome windows application that will do exactly what your looking for called "Text Blaze". I found it in the Microsoft store, but you might be able to find it else where. It's not isolated to AutoCAD though, any shortcuts you set will apply to any program.

 


Jonathan Norton
Blog | Linkedin