Lee Mac Posted February 13, 2017 Author Share Posted February 13, 2017 Thank you - I'm pleased to hear you were able to solve the problem! Quote Link to comment Share on other sites More sharing options...
Least Posted February 13, 2017 Share Posted February 13, 2017 Hi Lee, I use this lisp generally just using the single line text setting. Is it easy to change the lisp so that a forward slash is not seen as a new word. For instance: IR --> I/R but R --> Ridge --> this ends up as I/Ridge as the forward slash seems to be seen as a new word. I guess it would be good if the 'search and replace' strings could be run in a predetermined order, but I'm almost certain your not looking to rewrite this lisp any time soon.. On other thing, is there an easy way to restrict the single line text setting to only apply to a certain layer? Or is it easier to put a wrapper around this lisp to lock all but the one layer and then unlock them after? It would be amazing if any replaced text strings could then be moved to a pre-set layer, just rambling, the '/' issue is my main issue. Thanks for your time and great lisps. P Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 13, 2017 Author Share Posted February 13, 2017 I guess it would be good if the 'search and replace' strings could be run in a predetermined order, but I'm almost certain your not looking to rewrite this lisp any time soon.. I haven't looked back over the code for this application in detail, but I believe the program will perform the replacements in the order in which they appear in the list, therefore, if you were to enter the replacements as: Find: R Replace: Ridge Find: IR Replace: I/R Then you should hopefully obtain the desired result. On other thing, is there an easy way to restrict the single line text setting to only apply to a certain layer? Or is it easier to put a wrapper around this lisp to lock all but the one layer and then unlock them after?It would be amazing if any replaced text strings could then be moved to a pre-set layer, just rambling, the '/' issue is my main issue. As a quick workaround for this - you could change lines 1318-1322 from: (not (and (= 2 (logand 2 bit)) (vl-position (strcase (vla-get-layer obj)) lkl) ) ) to: (= "YOURLAYERHERE" (strcase (vla-get-layer obj))) Where YOURLAYERHERE is the layer you wish to modify (this must be uppercase!) I hope this helps! Quote Link to comment Share on other sites More sharing options...
Grrr Posted February 14, 2017 Share Posted February 14, 2017 Lee, I didn't knew what to expect, after seeing these dialogs in your main post, So I just checked your code - just to see whats like writing a COMPLETE program and It looks like your creating your own AutoCAD! (literally) Also I've found some nice subfunctions inside. Good job, mate! P.S. I knew about this thread quite a while, but just now I could appreciate the effort you did put in this project. Quote Link to comment Share on other sites More sharing options...
Least Posted February 14, 2017 Share Posted February 14, 2017 I hope this helps! Brilliant I will give it a go. Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2017 Author Share Posted February 14, 2017 Brilliant I will give it a go. Thanks You're welcome Least - I hope it works as expected. Lee,I didn't knew what to expect, after seeing these dialogs in your main post, So I just checked your code - just to see whats like writing a COMPLETE program and It looks like your creating your own AutoCAD! (literally) Also I've found some nice subfunctions inside. Good job, mate! P.S. I knew about this thread quite a while, but just now I could appreciate the effort you did put in this project. Thank you for your kind words and appreciation Grrr - the development of this particular application did indeed involve a great deal of work, mostly to accommodate the majority of MText formatting which could be present within the content of annotation objects which support such formatting, whilst also performing the find & replace operations around it... That said, the code for this program is now 7 years old and is in dire need of a complete overhaul. If you were looking for a more representative example, you might wish to look at the code for my Incremental Numbering Suite or Batch Attribute Editor which are more recently & extensively developed applications. Quote Link to comment Share on other sites More sharing options...
Least Posted February 15, 2017 Share Posted February 15, 2017 I haven't looked back over the code for this application in detail, but I believe the program will perform the replacements in the order in which they appear in the list, therefore, if you were to enter the replacements as: Find: R Replace: Ridge Find: IR Replace: I/R Then you should hopefully obtain the desired result. Looks like the routine sorts the list into alphabetical order on import. I have had a look, is it this function _sortbyfirst? Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 15, 2017 Author Share Posted February 15, 2017 Looks like the routine sorts the list into alphabetical order on import.I have had a look, is it this function _sortbyfirst? Sorry, I thought you were entering the items manually - change line 748 from: (vl-sort lst (function (lambda ( a b ) (< (car a) (car b))))) to: lst Quote Link to comment Share on other sites More sharing options...
Least Posted February 15, 2017 Share Posted February 15, 2017 That's worked perfectly. Many thanks! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 16, 2017 Author Share Posted February 16, 2017 Excellent - you're most welcome! Quote Link to comment Share on other sites More sharing options...
K Baden Posted August 2, 2017 Share Posted August 2, 2017 I am looking for something very similar to this. using this program to create the list of things i need to change would be extremely useful, as altering a code to add things manually leaves for human error (I am very new to coding) So basically, what I want is exactly what you've got, but I want to be able to put the predefined find and replace within another larger command (basically it just cleans up our drawings with 6 or so commands at once). In short, I want to be able to type in a command and have this done automatically, with no user intervention. making it human error proof for my large group of drafters. I need it to only evaluate the current drawing, and look only in text/mtext/multileaders. I want to embed this concept within another command so its done automatically with no user intervention. is this possible? Just to clarify, I am REALLY new to autoLISP and things of the sort, so I really appreciate very cut nd dry codes or advice. I've been trying to write this code by using a lot of different things I've found, but no idea how to make it do what i want. in fact, I will place a copy of the code that we already have that is so close to what i want, but not quite there. It searches attributes only, and i need it to search text/mtext, but simply don't have the knowledge to bend the code to what i need. any advice, or fixes would be GREATLY appreciated. (defun attreplace (old new / aval) (vlax-for n (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for m n (if (and (= "AcDbBlockReference" (vla-get-objectname m)) (= :vlax-true (vla-get-hasattributes m))) (foreach a (vlax-invoke m 'getattributes) (setq aval (vla-get-textstring a)) (while (vl-string-search old aval) ;;<- look for string (setq aval (vl-string-subst new old aval )) ;;<-replace here ) (vla-put-textstring a aval) ) )) )) (attreplace "TECHNOLOGIES" "TECH") (attreplace "COMMUNICATION COMPONENTS INC." "COMM COMPONENTS") (attreplace "DUAL BAND" "DB") (attreplace "Remote Radio Head" "Rem Radio Hd") (attreplace "Other - With RF" "Other-W/ RF") (attreplace "Other - Without RF" "Other-W/O RF") (attreplace "COMMUNICATIONS" "COMM") (attreplace "COMMUNICATION" "COMM") (attreplace "TECHNOLOGY" "TECH") (attreplace "FULL BAND" "FB") (attreplace "MASTHEAD" "MSTHD") (attreplace "DUAL DUPLEX" "DD") (princ) ) As you can see, this is very cut and dry with where/how to add new things for it to search for. I love the setup of this code. Can anyone direct me to how i should alter this for text/mtext? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted August 2, 2017 Share Posted August 2, 2017 This may be useful: https://www.cadsite.be/smf/index.php?topic=6567.msg34649#msg34649 Quote Link to comment Share on other sites More sharing options...
K Baden Posted August 2, 2017 Share Posted August 2, 2017 My god you are my savior. This works beautifully!! I can't thank you enough, I've been searching for this for weeks!!! Quote Link to comment Share on other sites More sharing options...
Dadgad Posted August 3, 2017 Share Posted August 3, 2017 My god you are my savior. This works beautifully!! I can't thank you enough, I've been searching for this for weeks!!! All of Lee's lisps are fantastic, but this one is truly mind blowing, I love whenever I get to use it! Thanks Lee! Quote Link to comment Share on other sites More sharing options...
vapenvila Posted April 20, 2018 Share Posted April 20, 2018 Hello One more here that has to say "Thank you" for the great amount of time saved by this Lisp in particular. I am having a strange result that I would like to ask: When I have a MTEXT (plain text, no heavy format) as a block attribute, and I replace, it duplicates the replacement i.e.: I want to replace "Hello" by "Hi". For a "Hello" I get "HiHi". If I then replace "HiHi" for "Hi" I end up getting what I wanted. Any idea on why this happens and how to solved if possible? Thank you so much again Regards Quote Link to comment Share on other sites More sharing options...
3dwannab Posted July 10, 2018 Share Posted July 10, 2018 Would there be a version in the future to support regular expression replacement? PS. I love this program. Quote Link to comment Share on other sites More sharing options...
koopalola Posted September 29, 2018 Share Posted September 29, 2018 First of all, I want to thank you Lee Mac for this excellent LISP. I found the interface very helpful and it is amazing that you are able to import a batch of strings from a separate txt file as your search material. I have done a lot of searches with this lisp but a couple of days ago I got some weird results. For some reason the report is contradictory. Basically if my find-string was "A" and replace string "B" the report says that it has made a replacement C --> D. So the report says that it has made a replacement of a text-string that was not included in the search anyhow. I'm quite confident that there is a logical explanation behind this but it is weird that it has performed well earlier and now I have met these problems. Do you guys have a clue what might be the cause of this? Quote Link to comment Share on other sites More sharing options...
dirtyacc Posted September 17, 2019 Share Posted September 17, 2019 (edited) the sub function _ReplaceText change string to list the add char code in the list will break the vba regex replace function with non-ASCII character like Chinese or Japenese I change it to below code will make it work, basically, it will lose the format manipulate, but it will has no error anyway. (defun _ReplaceText ( newstr oldstr str case whole / ) (_RegExReplace newstr oldstr str) ) Would you please update you code to support no-ASCII character? Here is a dwg with a Chinese single-line text enity. Drawing2.dwg Edited September 17, 2019 by dirtyacc Quote Link to comment Share on other sites More sharing options...
fatima-ezzahramohtich Posted July 9, 2021 Share Posted July 9, 2021 Thank you so much for this solution. Can I replace a one line text by a multiline text ? If yes, I would be grateful if you can help me to do it Quote Link to comment Share on other sites More sharing options...
asos2000 Posted July 12, 2021 Share Posted July 12, 2021 On 7/9/2021 at 11:28 AM, fatima-ezzahramohtich said: Thank you so much for this solution. Can I replace a one line text by a multiline text ? If yes, I would be grateful if you can help me to do it if Its one txt 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.