afritz0108 Posted Sunday at 04:22 PM Share Posted Sunday at 04:22 PM Hello all, im looking for a script or lisp that can change text inside a block on multiple drawings. I have no experience with Autocad Lisp. I’ve attached the block. Is there a way to change the text to whatever I need? Block.dwg Quote Link to comment Share on other sites More sharing options...
rlx Posted Sunday at 10:16 PM Share Posted Sunday at 10:16 PM I would advise visiting the site of the grand master of lisp Lee Mac and try to use his batch find and replace. https://lee-mac.com/bfind.html 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted 17 hours ago Share Posted 17 hours ago I use this for find and replace: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-and-replace-text/td-p/5649883 Does attribute text and non attribute text (think Lees only does attribute text? Though it is very quick and very good to change attributes as a batch on lots of drawings.). I'd use it with Lees sriptwriter function. If I am changing only attributes - use Lees Quote Link to comment Share on other sites More sharing options...
afritz0108 Posted 11 hours ago Author Share Posted 11 hours ago Steven What would I need to change on the code for it to work? Also how does it work on multiple drawings? Currently it says error too few arguments Quote Link to comment Share on other sites More sharing options...
Steven P Posted 11 hours ago Share Posted 11 hours ago You'll need to send the correct inputs to this LISP to make it work, something like this: (defun c:txtFindReplace( / old_text new_text) (setq old_text (getstring T "OLD Text to replace (replace in this model/paper space and text case as entered): ")) (setq new_text (getstring T "NEW Text: ")) (c:FindReplaceAll old_text new_text) (princ) ) All you really need is this line: (c:FindReplaceAll old_text new_text) I think this works with Lees ScriptWriter and also Scriptwriterpro: _.Open *file* FindReplaceAll "Old Text" "New Text" _.Saveas *file* _.Close something like that Quote Link to comment Share on other sites More sharing options...
afritz0108 Posted 10 hours ago Author Share Posted 10 hours ago Would I replace old_text & new_text with what I want to change? Quote Link to comment Share on other sites More sharing options...
Steven P Posted 9 hours ago Share Posted 9 hours ago Yes, so try this to see it work, open a drawing or start a new drawing and insert some text, go old school and "Hello world", load up the LISP from my AutoDesk link an also the c:textfindreplace LISP Now try this and noting the " " either side of the 2 text strings (c:FindReplaceAll "Hello World" "Goodbye World") This should change the text. You do the same, insert or create a block and again insert a text into the block and also an attribute. Put text to be maybe "Hello World", and change the attribute to be "Goodbye World".. you should have a block and a text, then run the line again, perhaps this time: (c:FindReplaceAll "Goodbye World" "Hello World") and with luck all 3 texts will all say Hello World. Try again without the capitals and and since the LISP is case sensitive nothing will change. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted 2 hours ago Share Posted 2 hours ago Try this subtle change saves typing one find variable. You can copy parts of the text from command line and use in new text the T supports spaces in new string. ; Findreplaceall By Terry Cad 2006 (defun c:txtFindReplace( / strold strnew) (if (not Findreplaceall)(load "findreplaceall.lsp")) (while (setq ent (car (nentsel "\nPick source text Enter to exit "))) (setq obj (vlax-ename->vla-object ent)) (setq strold (vlax-get obj 'textstring)) (setq strnew (getstring (strcat "\nReplace " strold " with ? ") T)) (c:FindReplaceAll strold strnew) ) (princ) ) (c:txtFindReplace) findreplaceall.lsp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.