therock005 Posted May 21, 2010 Share Posted May 21, 2010 I am looking for a way that I can gather all text inside a drawing and can massively edit it at will. I know that AutoCAD has a built-in function that allows for batch find and replacing, and that other routines similar exist, but i find it a limitation that you have to search for a specific string. What i need is a function that lists all available text inside the whole drawing or maybe within a specified drawing area, and then replace each instance with the desired end-result. How can i get some help on this? Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 21, 2010 Share Posted May 21, 2010 I think you need to be more specific when say that FIND command have limitations for your case. Also, may ask a moderator to move your post in AutoLISP, VBA, the CUI & Customisation section. Regards, Quote Link to comment Share on other sites More sharing options...
Dana W Posted May 21, 2010 Share Posted May 21, 2010 Edit > Find > Find Where: Selected objects First you select your text objects and do the above. You can check 'Replace All'. Wait, you did mention you wanted more than one string at a time to be edited. Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 21, 2010 Share Posted May 21, 2010 What an odd request. Fun to write... DosLib required. (defun c:EAT (/ ss sLst eLst nLst) ;; Edit All Text (playing around) ;; DosLib Required ;; Alan J. Thompson, 05.21.10 (if (and (or dos_proplist (alert "DosLib required. Please download and install.") (command "_.browser" "http://www.en.na.mcneel.com/doslib.htm") ) (setq ss (ssget "_X" '((0 . "ATTDEF,MTEXT,MULTILEADER,TEXT")))) ) (progn ((lambda (i) (while (setq e (ssname ss (setq i (1+ i)))) ((lambda (ent) (or (eq 4 (logand 4 (cdr (assoc 70 (entget (tblobjname "layer" (cdr (assoc 8 ent))))))) ) ((lambda (str) (setq sLst (cons (cons str str) sLst) eLst (cons e eLst) ) ) ((lambda (s) (cond ((eq (cdr (assoc 0 ent)) "MULTILEADER") (cdr (assoc 304 ent))) ((vl-position (cdr (assoc 0 ent)) '("ATTDEF" "MTEXT" "TEXT")) (foreach x ent (and (vl-position (car x) '(1 3)) (setq s (strcat s (cdr x)))) ) s ) ) ) "" ) ) ) ) (entget e) ) ) ) -1 ) (if (and sLst eLst) (if (setq nLst (dos_proplist "Edit All Text" "Edit text:" sLst)) (mapcar (function (lambda (e s) (or (eq "" (cdr s)) (eq (car s) (cdr s)) (vla-put-textstring (vlax-ename->vla-object e) (cdr s)) ) ) ) eLst nLst ) ) (alert "No text on unlocked layers!") ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
therock005 Posted May 21, 2010 Author Share Posted May 21, 2010 But odd is good though, i hope! Thank you for being such a team player!!! This will help me a lot in the future. But could it be tweaked a little bit further and allow me to specify the region i want the text to be in? Cause with this method all text is displayed, and now i have this drawing with over 700 text entries and i get lost with what i want to replace!!! But great effort, i wonder why no one else finds this productive! Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 21, 2010 Share Posted May 21, 2010 Selection method (this I kind of like)... (defun c:EAST (/ ss sLst eLst nLst) ;; Edit All Selected Text ;; DosLib Required ;; Alan J. Thompson, 05.21.10 (if (and (or dos_proplist (alert "DosLib required. Please download and install.") (command "_.browser" "http://www.en.na.mcneel.com/doslib.htm") ) (setq ss (ssget "_:L" '((0 . "ATTDEF,MTEXT,MULTILEADER,TEXT")))) ) ((lambda (i) (while (setq e (ssname ss (setq i (1+ i)))) ((lambda (str) (setq sLst (cons (cons str str) sLst) eLst (cons e eLst) ) ) ((lambda (s ent) (cond ((eq (cdr (assoc 0 ent)) "MULTILEADER") (cdr (assoc 304 ent))) ((vl-position (cdr (assoc 0 ent)) '("ATTDEF" "MTEXT" "TEXT")) (foreach x ent (and (vl-position (car x) '(1 3)) (setq s (strcat s (cdr x)))) ) s ) ) ) "" (entget e) ) ) ) (if (setq nLst (dos_proplist "Edit All Text" "Edit text:" sLst)) (mapcar (function (lambda (e s) (or (eq "" (cdr s)) (eq (car s) (cdr s)) (vla-put-textstring (vlax-ename->vla-object e) (cdr s)) ) ) ) eLst nLst ) ) ) -1 ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 21, 2010 Share Posted May 21, 2010 I also updated the original to ignore objects on locked layers. Quote Link to comment Share on other sites More sharing options...
therock005 Posted May 22, 2010 Author Share Posted May 22, 2010 Oh man thanx a lot, this really really helps. I requested it cause at times i name the vertices of polygons, like A1,A2,A3,A50,A51... and i may decide at later point to add or remove vertices, so i will have to renumber the points affected. Imagine having to do this manually without some kind of help! That's one of the main reasons i wanted that. But at times i find myself wanting to edit lots of text inside a drawing. And selecting them one by one and going to properties to change their caption is completely tiresome when you have to deal with lots of text. Once again, thank you Alan! Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 22, 2010 Share Posted May 22, 2010 Come to think of it, long ago, I saw some really old text editors that would allow up to 3 text objects to be selected for editing. I'll have to remember to put it in my LSP folder and load it when I get to work on Monday; never know, might have a use for it. Enjoy and you're welcome. Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 22, 2010 Share Posted May 22, 2010 Tiny fix.... Quote Link to comment Share on other sites More sharing options...
Coosbaylumber Posted May 23, 2010 Share Posted May 23, 2010 In my older version of Acad sitting at home, is a simple routine to revise all text via the surround box method, then only hitting the text type box. It near instantly revises all text boxed up. It will array a selection of type fonts and their attributes and you then select the text style you want to see then. Do a purge and it will get rid of all text styles not used in the drawing. Does not work on XREFs or INSERTS though. A standard feature back then. Wm. Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 23, 2010 Share Posted May 23, 2010 In my older version of Acad sitting at home, is a simple routine to revise all text via the surround box method, then only hitting the text type box. It near instantly revises all text boxed up. It will array a selection of type fonts and their attributes and you then select the text style you want to see then. Do a purge and it will get rid of all text styles not used in the drawing. Does not work on XREFs or INSERTS though. A standard feature back then. Wm. I'm curious. Let's see it. Here's a very very simple and crude way... (defun c:Test (/ ss) (if (setq ss (ssget "_:L" '((0 . "MTEXT,MULTILEADER,TEXT")))) ((lambda (i) (while (setq e (ssname ss (setq i (1+ i)))) (command "_.ddedit" e "") ) ) -1 ) ) (princ) ) Would be a lot nicer with MText with multiple lines. Quote Link to comment Share on other sites More sharing options...
therock005 Posted November 1, 2018 Author Share Posted November 1, 2018 Is it possible that you can add a text selector, so that you can limit the selection to a specific range? So i can select some texts and then invoke the lisp routine. Cause some drawing have hundreds of texts and it still get overwhelming most of the time. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 2, 2018 Share Posted November 2, 2018 Your answer may be in the SSGET used in the code do a little home work using help etc to see what the options do. A hint you can have no automatic selection but still filter for text mtext etc. 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.