pmadhwal7 Posted July 11, 2023 Posted July 11, 2023 Hi all i have a too many text objects that need to be renumbered and i want to update them all at once by selecting them. like select text and do the number 1,2,3,4.... i have a lisp file but only thing is that lisp working only one by one text can anyone modify it or help me another code. text numbering-2ctx+.lsp Quote
Steven P Posted July 11, 2023 Posted July 11, 2023 That was the plan for that LISP, one at a time to cater for texts that is not regularly spaced. You could look to Lee Macs website incremental arrays (http://lee-mac.com/incrementalarray.html). If that doesn't do it for you post a drawings so we can see what you want to do, Quote
pmadhwal7 Posted July 13, 2023 Author Posted July 13, 2023 what i understand from lisp example video that text should be in same angle, but text which i have in my file are not equal angle and text are existing too. for more info sample file attached sample.dwg Quote
Steven P Posted July 13, 2023 Posted July 13, 2023 I'm not sure which numbers you are are increasing and what to Quote
pmadhwal7 Posted July 13, 2023 Author Posted July 13, 2023 7 hours ago, Steven P said: I'm not sure which numbers you are are increasing and what to Over the shot length text written 1,2,3 Quote
Steven P Posted July 13, 2023 Posted July 13, 2023 Looking to see if there is a rule you can apply to that so you can select a large area and it will work it out. For example, do they all increase in value by the same amount or in an order say, left to right? Most of the text apart from these in the sample is mtext but there are a couple of other texts as well - so how to remove these from a selection what rule would you apply there. Just incrementing the numbers is easy but distinguishing which ones to increase is the hard part (which is why I made up the one you posted). I guess you could find all the texts that contain "shot Length" (ssget filters 0 for Mtext and 1 for "*Shot Length*"), then create a selection from texts that are close to them (get the bounding box of the "Shot Texts" in a while loop, offset that by a distance, ssadd a selection set using crossing polyline filtered for text), then working left to right with these texts check that the text is a number (reduces the number of bad changes) and increment each in turn. Some internet searching will give you the building blocks here, just got to work out the process. A bit of a task to write, check, test, verify and use. How often will you do this task? Point being is it worth the time to do all of that for a task you only do once or twice as year if you have something that will do half of it? Or will this save enough time a week to make it worthwhile? Second thought here is versatility, if you do as I think you can, use "Shot Length" Mtext for the location will you have a lot of other drawings with that text and with the number in question close enough to do as I think you can? Just trying to work out the rules to set in a LISP to make this work and if it is going to save a lot of time. Quote
pmadhwal7 Posted July 18, 2023 Author Posted July 18, 2023 On 7/13/2023 at 10:01 PM, Steven P said: Looking to see if there is a rule you can apply to that so you can select a large area and it will work it out. For example, do they all increase in value by the same amount or in an order say, left to right? Most of the text apart from these in the sample is mtext but there are a couple of other texts as well - so how to remove these from a selection what rule would you apply there. Just incrementing the numbers is easy but distinguishing which ones to increase is the hard part (which is why I made up the one you posted). I guess you could find all the texts that contain "shot Length" (ssget filters 0 for Mtext and 1 for "*Shot Length*"), then create a selection from texts that are close to them (get the bounding box of the "Shot Texts" in a while loop, offset that by a distance, ssadd a selection set using crossing polyline filtered for text), then working left to right with these texts check that the text is a number (reduces the number of bad changes) and increment each in turn. Some internet searching will give you the building blocks here, just got to work out the process. A bit of a task to write, check, test, verify and use. How often will you do this task? Point being is it worth the time to do all of that for a task you only do once or twice as year if you have something that will do half of it? Or will this save enough time a week to make it worthwhile? Second thought here is versatility, if you do as I think you can, use "Shot Length" Mtext for the location will you have a lot of other drawings with that text and with the number in question close enough to do as I think you can? Just trying to work out the rules to set in a LISP to make this work and if it is going to save a lot of time. Hi, Just required to change those red circle number only not shot length and those text are not in equal rotation and positions Quote
Steven P Posted July 18, 2023 Posted July 18, 2023 I think I would go for the option to select and increment each number one at a time here, would be less prone to errors and for example there are the numbers above the 'Shot' that you want but also the larger numbers making selecting everything and distinguishing which to increment trickier (possible, just trickier). 1 Quote
pmadhwal7 Posted July 18, 2023 Author Posted July 18, 2023 3 hours ago, Steven P said: I think I would go for the option to select and increment each number one at a time here, would be less prone to errors and for example there are the numbers above the 'Shot' that you want but also the larger numbers making selecting everything and distinguishing which to increment trickier (possible, just trickier). we can filter those text by height and those are direct text too shot length text and other are multi text Quote
Steven P Posted July 18, 2023 Posted July 18, 2023 You can have a go - not something I would do to be honest, far too specific for a single solution. OK, you might have hundreds of these drawings to do, but to write, check, verify, try to break a code before you finally use it usually is more time consuming than just doing it for a few drawings (of course, other times I do that just because I can) This will select all the text that is a height of 2 (according to your drawing) (refer to Lee Macs website for ssget references - his is probably the easiest for me to understand) (setq MySS (ssget "X" '((0 . "TEXT")(40 . 2)))) This will loop through the selection set and update your text. (setq acount 0) (while (< acount (sslength MySS)) (setq MyEnt (ent get (ssname MySS acount)) ) ;;Do Your text changes here, save as variable NewText ;;https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-C7D27797-247E-49B9-937C-0D8C58F4C832 (setq MyEnt (subst (cons 1 NewText) (assoc 1 MyEnt) MyEnt )) ;; (entmod MyEnt) (setq acount (+ acount 1)) ) ;; end while and how you want to do the texts and any verification that each is a number is up to you - loads of options out there. The simplest would be a mix of the ascii and chr functions with a +1 which would increase by 1 the last digit and no error checking that the text is a number. There is a method out there to add all the ascii characters together so that +1 will do 10s,, 100's and so on if necessary (this method will work for letters if you ever get that case. versatility), or else you want to do a check that the text string is a number (this is all online somewhere), convert to a number then +1 (use ATOI for integers, ATOF if you might have decimal places) Remember that NewText has to be a string, if you calculation gives you a number it wants to be (rtos Newtext) in the substitution line You might want to add in start and end undo markers in case it all goes wrong sometime (this is online), How long you spend making it nice depends how often you will use this, but the basics are above, and in the original thread you copied the code from (always good to give a link to there, there are other ideas in that thread if what you posted doesn't work for others following you) 1 Quote
pmadhwal7 Posted July 19, 2023 Author Posted July 19, 2023 11 hours ago, Steven P said: You can have a go - not something I would do to be honest, far too specific for a single solution. OK, you might have hundreds of these drawings to do, but to write, check, verify, try to break a code before you finally use it usually is more time consuming than just doing it for a few drawings (of course, other times I do that just because I can) This will select all the text that is a height of 2 (according to your drawing) (refer to Lee Macs website for ssget references - his is probably the easiest for me to understand) (setq MySS (ssget "X" '((0 . "TEXT")(40 . 2)))) This will loop through the selection set and update your text. (setq acount 0) (while (< acount (sslength MySS)) (setq MyEnt (ent get (ssname MySS acount)) ) ;;Do Your text changes here, save as variable NewText ;;https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-C7D27797-247E-49B9-937C-0D8C58F4C832 (setq MyEnt (subst (cons 1 NewText) (assoc 1 MyEnt) MyEnt )) ;; (entmod MyEnt) (setq acount (+ acount 1)) ) ;; end while and how you want to do the texts and any verification that each is a number is up to you - loads of options out there. The simplest would be a mix of the ascii and chr functions with a +1 which would increase by 1 the last digit and no error checking that the text is a number. There is a method out there to add all the ascii characters together so that +1 will do 10s,, 100's and so on if necessary (this method will work for letters if you ever get that case. versatility), or else you want to do a check that the text string is a number (this is all online somewhere), convert to a number then +1 (use ATOI for integers, ATOF if you might have decimal places) Remember that NewText has to be a string, if you calculation gives you a number it wants to be (rtos Newtext) in the substitution line You might want to add in start and end undo markers in case it all goes wrong sometime (this is online), How long you spend making it nice depends how often you will use this, but the basics are above, and in the original thread you copied the code from (always good to give a link to there, there are other ideas in that thread if what you posted doesn't work for others following you) Hi, Please tell me how to use this Quote
Steven P Posted July 19, 2023 Posted July 19, 2023 (edited) So I reckon you have read enough on here to be able to write a simple LISP yourself - start one off for this task and use the ideas I posted above I think all you will need to do is copy and paste the code into it. Check that what I have works by making the word NewText a value rather than a variable by putting speech marks either side of it, "NewText" which will change all the required text to that value. Or change the variable to this (rtos acount). Example below what to change. That will let you check that basic code works. After have a look to see how to get the text into a variable to update (hint below) and see how you go from there, take it as far as you can and then we can give more help - it is quite satisfying making up your own code, and most of us are happy to help you along the way ;;This replaces all the selected text with the word "Newtext" (setq MyEnt (subst (cons 1 "NewText") (assoc 1 MyEnt) MyEnt )) ;;This replaces all the selected text with a number (the counter used in loping through the texts) (setq MyEnt (subst (cons 1 (rtos acount) ) (assoc 1 MyEnt) MyEnt )) ;;Hint ;;This extracts the text from an entity (setq MyText (cdr (assoc 1 MyEnt))) EDIT: In your LISPs the tasks you want to do are: - Select all the required texts using a selection set and filter - Use a while loop to go through all these texts - Use ATOI to change the string you get from the text to be a number, then add 1 to it - change the text using subst and entmod - end the while loop Edited July 19, 2023 by Steven P Quote
Steven P Posted July 21, 2023 Posted July 21, 2023 Did you get very far with this having a go yourself? Quote
Steven P Posted July 21, 2023 Posted July 21, 2023 Let us know how you do, and ask for help along the way Quote
pmadhwal7 Posted July 22, 2023 Author Posted July 22, 2023 In fact due to circumstances I still haven't tried to create. Quote
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.