suryatry26 Posted February 23, 2015 Share Posted February 23, 2015 Have any idea about find and replace the text with Excel (Or .txt file) input file Please see below. Am using Autocad 2014. I have clear data for Existing Text & Replacing text content. Please see below. 1000Amp (Existing Text in Cad File) Need to Change As 750Amp 500Amp (Existing Text in Cad File) Need to Change As 200Amp 2500Amp (Existing Text in Cad File) Need to Change As 150Amp Like this i have nearly 100 text need to change. So each time find and replacement its taking more time. So if i have this option with excel or txt file means its too easy for more text updating. Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 24, 2015 Author Share Posted February 24, 2015 Any one help me please? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 24, 2015 Share Posted February 24, 2015 Show me the contents / format of that txt file / excel file ? Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 24, 2015 Author Share Posted February 24, 2015 I have the input file with excel format.. Here I try to upload.. But I cant able to upload the Excel (Txt file also). Its continually processing while try to upload... File size just 200KB. Have 2 Columns in Excel File One is Actual Text Another One is Need to Change As.. This Changes need to be in Cad File . Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 24, 2015 Share Posted February 24, 2015 The first column obtain the text string that to be searched for and the second column would obtain the new replaced text string ? Upload a snapshot as long as you can't upload the file itself . I need to see a few lines starts from the top of the file to write a routine in one shot . Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 24, 2015 Author Share Posted February 24, 2015 I tried to upload snapshot... But No Use.. The first column obtain the text string that to be searched for and the second column would obtain the new replaced text string ? Yes You are right. If First Column 1000Amp mentioned means its should find 1000Amp and need to replace this data with Column 2 (Ex :250Amp) Text Content.. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 24, 2015 Share Posted February 24, 2015 Try this program that I honestly did not test it , so let me know how you get on with it . NOTE: Your Excel file should be with the extension of CSV to be able to select the file . (defun c:Test (/ *error* fl on _parse:strings st l sel i sn e f) ;;; Author: Tharwat . 24.02.2015 ;;; ;;; ---------------------------- ;;; (defun *error* (msg) (if on (close on) ) (if (not (and msg (wcmatch (strcase msg) "*CANCEL*,*EXIT*,*BREAK*")) ) (princ "\n** Error Found :" msg " !! **") ) (princ) ) (if (and (setq fl (getfiled "Select Excel file :" (getvar 'dwgprefix) "csv" 16 ) ) (setq on (open fl "r")) ) (progn (defun _parse:strings (string delimiter / pos lst) ;;; Parse a string to a list of strings ;;; ;;; as per the delimiter ;;; (while (setq pos (vl-string-search delimiter string 0)) (progn (setq lst (cons (substr string 1 pos) lst)) (setq string (substr string (+ pos 2) (strlen string))) ) ) (if (and string (/= string "")) (setq lst (cons string lst)) ) (setq lst (reverse lst)) ) (while (setq st (read-line on)) (setq l (cons (_parse:strings st ";") l)) ) (if (setq sel (ssget "_X" (list '(0 . "TEXT") (cons 1 (apply 'strcat (mapcar '(lambda (s) (strcat s ",")) (mapcar 'car l) ) ) ) ) ) ) (repeat (setq i (sslength sel)) (setq sn (ssname sel (setq i (1- i))) e (entget sn) ) (if (and (setq f (assoc (cdr (assoc 1 e)) l)) (vlax-write-enabled-p (vlax-ename->vla-object sn)) ) (entmod (subst (cons 1 (cadr f)) (assoc 1 e) e)) ) ) ) (close on) ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
EBROWN Posted February 24, 2015 Share Posted February 24, 2015 I think BFindV2-0.lsp from Lee's web site would do the trick. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 25, 2015 Share Posted February 25, 2015 Manually you can use FIND which has search/replace but I have not seen a lisp version that could then use a script etc. Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 25, 2015 Author Share Posted February 25, 2015 Tharwat I tried but there is no action done..in Csv I have to mentione with 2 data's? 1 is Existing Text Content & another one is Which Text Content need to replace? Ebrown I already tried that BFindV2-0.lsp from Lee's web site . Using that one we cant upload the excel data's. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 25, 2015 Share Posted February 25, 2015 I just tried the program and it works as expected . I don't know how you run the program and how YOUR CSV excel file look like . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 25, 2015 Share Posted February 25, 2015 I think BFindV2-0.lsp from Lee's web site would do the trick. Thank you for the recommendation! Ebrown I already tried that BFindV2-0.lsp from Lee's web site . Using that one we cant upload the excel data's. There is a workaround for importing find/replace items, described here: http://www.cadtutor.net/forum/showthread.php?46135-Batch-Find-amp-Replace-Text&p=537625&viewfull=1#post537625 Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 25, 2015 Author Share Posted February 25, 2015 Tharwat Please see below. After load Lsp Simply I loaded this Csv. But there is no Action. A Column-B Column 1000Amp - 750Amp 500Amp - 200Amp 250Amp - 150Amp 1500Amp - 275Amp Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 25, 2015 Share Posted February 25, 2015 Tharwat Please see below. After load Lsp Simply I loaded this Csv. But there is no Action. *- Were you able to select the Excel file with the extension CSV ? *- You after to replace a SINGLE text objects or MTEXT text objects ? *- Are there any of these text strings is a part of long text or separate objects to be replaced ? Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 25, 2015 Author Share Posted February 25, 2015 Were you able to select the Excel file with the extension CSV ? I have the input with excel file.. then i save as to Csv Format. Then i have loaded while its asking load the Csv file. You after to replace a SINGLE text objects or MTEXT text objects ? I tried with Mtext and Text both. Are there any of these text strings is a part of long text or separate objects to be replaced ? Its a Separate Text (& Mtext) After run the Lsp there is no Action on Cad File. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 25, 2015 Share Posted February 25, 2015 Try the program on the following drawing with the Excel file to see how the program works . Test.dwg Book1.csv Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 25, 2015 Author Share Posted February 25, 2015 Its Working Superb. Thanks a Lot..It Wont Work With MTEXT??? Possible to Include MTEXT? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 25, 2015 Share Posted February 25, 2015 Its Working Superb. Thanks a Lot..It Wont Work With MTEXT??? Possible to Include MTEXT? Finally you got it working ! good for you You can add the Mtext objects , just add the following part as shown in red color . '(0 . "TEXT[color=red],MTEXT[/color]") Quote Link to comment Share on other sites More sharing options...
suryatry26 Posted February 25, 2015 Author Share Posted February 25, 2015 Its working fine now...Thanks a lot. Its not considering Space Text Like "BATTERY BANK". BATTERY BANK-01 Need To Change As BATTERY BANK-02 means what can I do? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 25, 2015 Share Posted February 25, 2015 Its not considering Space Text Like "BATTERY BANK". BATTERY BANK-01 Need To Change As BATTERY BANK-02 means what can I do? Nothing special in the program , just add as much as you want in the excel file (first column obtain the text string to search for then the second column obtain the text string to be replace ) But if you want to increment the value , that is NOT possible with this program . That's it . 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.