AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

text replace LISP

7 REPLIES 7
Reply
Message 1 of 8
automationstar
1420 Views, 7 Replies

text replace LISP

Hi All,

 

Anyone have a LISP for replacing text globally in a drawing regardless of where it lies?

e.g. text, mtext, attributes, nested attributes, attribute tags, attribute prompts and of course attribute values?

    Find wont do this

    CHT.lsp wont do this

 

This may seem like a frightening tool to Autodesk as well as any AcadE Cad Manager due to its power to potentially screw up an entire drawing set/database, but in the right hands is invaluable.

 

I made such a tool about 7 years ago based off the old CHT lisp routine and a few others, so I know it is possible.

Anyone?

 

Best Regards and thanks in advance,

 

AS

7 REPLIES 7
Message 2 of 8

You can change fonts and text sixe for attributes project wide via Project-wide Utilitles.  

 

Hint: AutoCAD Electrical refers to fonts as "Style" in the lower right of the utilities dialog.



Doug McAlexander


Design Engineer/Consultant/Instructor/Mentor specializing in AutoCAD Electrical training and implementation support

Phone and Web-based Support Plans Available

Phone: (770) 841-8009

www.linkedin.com/in/doug-mcalexander-1a77623




Please Accept as Solution if I helped you. Likes are also much appreciated.
Message 3 of 8

Not quite what I meant.  Lets say you want to change the value of custom attributes, (lets call it "PARTNO") within a block project wide.  Sure you could update the database and use the txtval field, but then you have to go back and relookup each block to pop that value in.

Message 4 of 8
Icemanau
in reply to: automationstar

From at least version 2014, there has been a function to update components from the catalog database.

 

In the example you gave, you would update the catalog, then run this tool. Select the required options (in this case it would be TextValue's) and select if you want it to be run on the project, Active Dwg (all) or Active Drawing (pick).

 

ACADE will then go through and update the relevant attributes.

 

The options are TextValue, Terminal Properties, Pin List Data with the sub option to Blank Existing Child Pin List Assignments and the last option is to update the WebLink.

 

Regards Brad

>

Brad Coleman, Electrical Draftsman
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

Message 5 of 8
automationstar
in reply to: Icemanau

Thanks for the review Icemanau, this tool would address the scenario, but still doesn't do all that I am asking, here is another example:

A panel identification number changed, I now need to replace: all device location codes, mtext and text references (non block text references), location box callouts, and titleblock attribute references to this incorrect location code throughout an entire project.

What single command would I use then to do all this?

Message 6 of 8
Icemanau
in reply to: automationstar

Have you looked at the Text Find & Replace tool.

 

It is a standard ACAD tool and looking at the 2014 release, it can search for specific text in Attributes, Dimension and Leaders, Single or Multi line text, Tables, Hyperlinks and their descriptions.

 

Start the tool and click on the down arrow in the bottom left corner to bring up all the options.

 

Of course, if you do use this to change an attribute, you MUST do a save and project rebuild straight afterwards to force the changes into the project database.

 

Regards Brad

>

Brad Coleman, Electrical Draftsman
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

Message 7 of 8
jalger
in reply to: automationstar

Hi Automationstar,

 

You could export the Component data (Export to Excel spreadsheet), and edit all of the Incorrect data in excel.

(Import/Export data> Export > to spreadsheet)

Then import it back into overwrtie the Incorrect values.

(Import/Export data> Import > from spreadsheet)

(you may need to export additional data to get everything your trying to edit- in this case probably Panel components)

 

I hope this helps,

 

James

James Alger
(I'm on several hundred posts as "algerj")

Work:
Dell Precision 5530 (Xeon E 2176M)
1tb SSD, 64GB RAM
Nvidia Quadro P2000, Win10
Message 8 of 8
MATTHEW.BROWNVGAGA
in reply to: jalger

Here's what I came up with

 

(defun c:replacetextmdb()
(setq olsosmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq p (ssget))
(if p
(progn
(setq osl (strlen (setq os (getstring "\nOld string: " t))))
(setq nsl (strlen (setq ns (getstring "\nNew string: " t))))
(setq l 0 chm 0 n (sslength p))
(setq adj
(cond
((/= osl nsl) (- nsl osl))
(T nsl)
)
)
(while (< l n)
(setq d (entget (setq e (ssname p l))))
(if (and (= (atext 0) "INSERT")(= (atext 66) 1))
(progn
(setq e (entnext e))
(while e
(setq d (entget e))
(cond
((= (atext 0) "ATTRIB")
(setq chf nil si 1)
(setq s (cdr (setq as (assoc 1 d))))
(while (= osl (setq sl (strlen
(setq st (substr s si osl)))))
(cond
((= st os)
(setq s (strcat (substr s 1 (1- si)) ns
(substr s (+ si osl))))
(setq chf t)
(setq si (+ si adj))
)
)
(setq si (1+ si))
)
(if chf
(progn
(setq d (subst (cons 1 s) as d))
(entmod d)
(entupd e)
(setq chm (1+ chm))
)
)
(setq e (entnext e))
)
((= (atext 0) "SEQEND")
(setq e nil))
(T (setq e (entnext e)))
)
)
)
)
(if (= "MTEXT" ; Look for MTEXT entity type (group 0)
(cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq chf nil si 1)
(setq s (cdr (setq as (assoc 1 e))))
(while (= osl (setq sl (strlen
(setq st (substr s si osl)))))
(if (= st os)
(progn
(setq s (strcat (substr s 1 (1- si)) ns
(substr s (+ si osl))))
(setq chf t) ; Found old string
(setq si (+ si nsl))
)
(setq si (1+ si))
)
)
(if chf (progn ; Substitute new string for old
(setq e (subst (cons 1 s) as e))
(entmod e) ; Modify the TEXT entity
(setq chm (1+ chm))
))
)
)
(if (= "DIMENSION" ; Look for DIMENSION entity type (group 0)
(cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq chf nil si 1)
(setq s (cdr (setq as (assoc 1 e))))
(while (= osl (setq sl (strlen
(setq st (substr s si osl)))))
(if (= st os)
(progn
(setq s (strcat (substr s 1 (1- si)) ns
(substr s (+ si osl))))
(setq chf t) ; Found old string
(setq si (+ si nsl))
)
(setq si (1+ si))
)
)
(if chf (progn ; Substitute new string for old
(setq e (subst (cons 1 s) as e))
(entmod e) ; Modify the TEXT entity
(setq chm (1+ chm))
))
)
)
(if (= "TEXT" ; Look for TEXT entity type (group 0)
(cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq chf nil si 1)
(setq s (cdr (setq as (assoc 1 e))))
(while (= osl (setq sl (strlen
(setq st (substr s si osl)))))
(if (= st os)
(progn
(setq s (strcat (substr s 1 (1- si)) ns
(substr s (+ si osl))))
(setq chf t) ; Found old string
(setq si (+ si nsl))
)
(setq si (1+ si))
)
)
(if chf (progn ; Substitute new string for old
(setq e (subst (cons 1 s) as e))
(entmod e) ; Modify the TEXT entity
(setq chm (1+ chm))
))
)
)
(setq l (1+ l))
)
)
)
(if (> chm 1)
(princ (strcat "\nUpdated " (itoa chm) " text strings"))
(princ (strcat "\nUpdated " (itoa chm) " text string"))
)
(setvar "OSMODE" oldosmode)
(terpri)
)
;

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

Post to forums  

Autodesk Design & Make Report

”Boost