Lawrst Posted April 19, 2018 Share Posted April 19, 2018 Hello all, When using the find command, is there a way (i assume there is and Im missing something) that i can do the following. Lets say i have a drawing full of numbers, wire numbers to be specific, that are along these lines: XXYYZ where XX is the page, YY is the line number and z is how many times that wire has changed (through a contact or switch etc). If i am copying an existing drawing and duplicating it, or simply having to change the drawing number, we need to go through the process of replacing the page numbers in all of these wires. So far find and replace does a good job but there are a few problems: The first problem with this, if i have a drawing that i page 30, on line 30, the first wire number on that line will be "30300". If i want to change that drawing number from 30 to 40 and do a find and replace, the previous wire number will become 40400, not 40300. Is there a way for me to replace only the first instance of 40? The output I'm looking for is changing "30300" to "40300" The other issue with this, is if i have a wire number that is "33050" (page 33, line 05, wire 0) that has comes from another drawing, find and replace it will change it to "34050". Is there a way that i can limit my search to only return values with the starting string as "30" and it will ignore cases like "33050"? This is only a basic example and they get more complicated and convoluted but i think if these can be done I will make my life easier going forward. Thank you to anyone who is able to help. Apologize if this is a bit long, but i didn't want to confuse anyone. P.S. For the power users: I only use this on older drawings that we need to modify for our client. For new drawings i have created a series of dynamic blocks in combination with fields that i use to avoid this issue. Currently I use a diesel expression that takes the sheet number from the DWG file name (it is always in the same spot, the last 2 numbers before ".dwg") and uses that. Am happy to hear anyone ideas on making this simpler or improving it. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 19, 2018 Share Posted April 19, 2018 As Find & Replace is a global style routine you need a custom routine that has rules built in that looks for specific text patterns and changes them. In lisp the substr function can be used. This is a very simple Example not code. (setq str "30300") (substr str 1 2 ) = 30 (strcat "new" (substr str 3)) = new300 Search for Change prefix. Quote Link to comment Share on other sites More sharing options...
Lawrst Posted April 19, 2018 Author Share Posted April 19, 2018 Very interesting... Didn't even think of using a lisp routine for this... Thanks! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted April 19, 2018 Share Posted April 19, 2018 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Quote Link to comment Share on other sites More sharing options...
dlanorh Posted April 20, 2018 Share Posted April 20, 2018 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. To change 30300 to 40300 using Find and Replace Find 303 Replace 403 otherwise it will find 30 twice in the same string Quote Link to comment Share on other sites More sharing options...
dlanorh Posted April 20, 2018 Share Posted April 20, 2018 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. There is also this http://www.lee-mac.com/bfind.html 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.