tmelancon Posted May 31, 2022 Posted May 31, 2022 (edited) I am in need of a LISP that will be used in a batch I will be running for a client on thousands of drawings before turning them over. Essentially I am trying to develop a LISP that would search all TEXT/MTEXT entities in a drawing and if it includes what we call "data readings" on the end (e.g., .128, .220, .000) then they need to be removed, else do nothing. Some very old drawings may not have the thousandths, only tenths and hundredths (e.g. .12, .07, 34...) but I need the LISP to ultimately remove the decimal and anything after it if it exist in the drawing. There are multiple instances of these within each drawings so they will all have different location names to which they are referring to on the pipe (e.g., PIPE, TEE, ELBOW, etc....), and also some may or may not have readings. The LISP would just skip those that do not have these readings. EXAMPLE (Datapoint Locations with data readings): #18.1- W-NIPPLE-D #19.9- PIPE .000 #26- TEE .318 #22.1- CUPS-PIPE .178 EXAMPLE RESULT AFTER SAID LISP RUNS (Datapoint Locations WITHOUT data readings): #18.1- W-NIPPLE-D [IGNORED BY LISP BECAUSE NO DATA READING WAS DETECTED] #19.9- PIPE [PROCESSED BY LISP AND .000 WAS REMOVED] #26- TEE [PROCESSED BY LISP AND .318 WAS REMOVED] #22.1- CUPS-PIPE [PROCESSED BY LISP AND .178 WAS REMOVED] ....continue for remaining Please see the sample images I have provided of a drawing before and after the LISP I am trying to develop. I thank you in advance for even giving my post the time of day and as always you guys rock and I appreciate you. Edited May 31, 2022 by tmelancon Quote
devitg Posted May 31, 2022 Posted May 31, 2022 For better understanding, and maybe get further help, please upload such sample.dwg and LSP 1 Quote
tmelancon Posted May 31, 2022 Author Posted May 31, 2022 I currently do not have LISP. I am in the research phase to develop something and I am seeking help from you all. Attached is a sample drawing. Sample Drawing Remove Reading.dwg Quote
Steven P Posted May 31, 2022 Posted May 31, 2022 How is your LISP programming? I haven't looked at this yet however if you can make up a LISP routine then the following might make some sense? Thinking quickly, Lee Mac has a string to List LISP, perhaps if you can use ssget to get the text and mtexts into a selection set (and perhaps other text types, dimensions or whatever if necessary). Loop through the selection set and use Lee Macs string to List using a '.' as the deliminator, checking the last list item - a check for string length (should be 3 characters long), and a check to see if it is a number (atoi ? ) - if it is not an error the last 4 characters of the text string is a number ".xyz".. maybe look for stringsearch to delete that or, since you have a list all ready strcat the list items with a '.' (the deliminator) between each.. apart from the last list item.. which will give the new text string, then something like vl-put-textstring or entmod that text item from the selection set. Hope that makes sense and might give you a way to go? Got stuff to do this evening, else might be tempted to have a go for you, 1 Quote
devitg Posted May 31, 2022 Posted May 31, 2022 Would all text be at this layer only ? The sample text is at other layer Quote
tmelancon Posted May 31, 2022 Author Posted May 31, 2022 @devitg our normal standard is text that contains a normal reading falls under the LOCAL-LINE-DATA blue layer. However, if we have a failing reading it defaults to LOCAL-LINE-HIGH red layer to stand out more. I am not totally concerned about specifying exact layers to look at which is simply why I want to look at all text and mtext entities but I guess we could add something like this to account for MTEXT and TEXT on layers ending in DATA and HIGH: (if (setq s (ssget "X" '((0 . "TEXT,MTEXT")(8 . "*DATA,*HIGH")))) I really appreciate you responding and helping me. I hope this answered your question. Quote
tmelancon Posted May 31, 2022 Author Posted May 31, 2022 @Steven P I will certainly consider all of your helpful information and apply this towards developing and testing something to achieve what I am looking for! Thanks for posting here I truly appreciate it! Hey if you take a stab at it and succeed then more power to you! Kudos to you for being awesome! I will keep at it on and off throughout my day when I have time. Will post updates as they come along. Cheers 1 Quote
ronjonp Posted May 31, 2022 Posted May 31, 2022 (edited) Try this ... does not check for locked layers. (defun c:foo (/ a i o s) (if (setq s (ssget "_X" '((0 . "TEXT") (1 . "* .#,* .##,* .###")))) (foreach e (mapcar 'cadr (ssnamex s)) (setq a (vla-get-textstring (setq o (vlax-ename->vla-object e)))) (setq i (vl-string-position 32 a 0 t)) (vla-put-textstring o (substr a 1 i)) ) ) (princ) ) Edited May 31, 2022 by ronjonp 4 Quote
tmelancon Posted May 31, 2022 Author Posted May 31, 2022 5 minutes ago, ronjonp said: Try this ... does not check for locked layers. (defun c:foo (/ a i o s) (if (setq s (ssget "_X" '((0 . "TEXT") (1 . "* .#,* .##,* .###")))) (foreach e (mapcar 'cadr (ssnamex s)) (setq a (vla-get-textstring (setq o (vlax-ename->vla-object e)))) (setq i (vl-string-position 32 a 0 t)) (vla-put-textstring o (substr a 1 i)) ) ) (princ) ) BRUHH!!! THIS IS EXACTLY WHAT I NEEDED! I am so grateful for your service to me and this website. I will research each line of code and reverse engineer it to learn more about what is taking place during each function. God bless you RONJONP !! Quote
ronjonp Posted May 31, 2022 Posted May 31, 2022 4 minutes ago, tmelancon said: BRUHH!!! THIS IS EXACTLY WHAT I NEEDED! I am so grateful for your service to me and this website. I will research each line of code and reverse engineer it to learn more about what is taking place during each function. God bless you RONJONP !! Glad you could make use it. Definitely test it out before shredding a directory of drawings. The filter will only grab end numbers up to 3 digits long so if there are any longer than that just keep adding # like so separated by commas: (1 . "* .#,* .##,* .###,* .####,* .#####") 2 Quote
tmelancon Posted May 31, 2022 Author Posted May 31, 2022 (edited) Hahaha Quote Definitely test it out before shredding a directory of drawings. That's spot on! Love that comment! So accurate. I will definitely test a handful individually/manually, and also on a small test directory so I ensure the end product is exactly what I want. You totally rock man! Edited May 31, 2022 by tmelancon 1 Quote
BIGAL Posted June 1, 2022 Posted June 1, 2022 (edited) Backup Backup Backup that is all I will say. USB sticks are cheap. Edited June 1, 2022 by BIGAL 1 Quote
tmelancon Posted June 1, 2022 Author Posted June 1, 2022 12 hours ago, BIGAL said: Backup Backup Backup that is all I will say. USB sticks are cheap. BIGAL KNOWS! Hahaha True experts know ALWAYS BACKUP!!!!! Thanks big dog! Cheers! Quote
exceed Posted June 2, 2022 Posted June 2, 2022 On 6/1/2022 at 4:42 AM, tmelancon said: Hahaha That's spot on! Love that comment! So accurate. I will definitely test a handful individually/manually, and also on a small test directory so I ensure the end product is exactly what I want. You totally rock man! Searches the text with (1 . "* .#,* .##,* .###,* .####,* .#####") format then finds where the ascii code 32 (space bar) is and fetches only the text before it. So, what to test for this complete and concise code is 1. are there any spaces after the decimal point in your drawing like "PIPE .123 ", "PIPE .123 ", "PIPE . 123" This will be filtered out by the ssget filter. But it's hard to see on thousands of drawings 2. or it will be or you used MTEXT, or the lock or freeze layer contains text 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.