stlo Posted August 25, 2022 Posted August 25, 2022 Hi everyone! I have 2 smalls codes that does exactly the same thing but for different text heights. We select all elements in a drawing, it finds all text elements with a certain height and it deletes it! The c:TE code works perfectly , the text height is 2.4. I'm having a problem with the c:ES one, the height is set to 1.5688 but it's not detecting those specific text elements? Is it because it's a roundup height number? If yes, how can I know the exact height of this specific text? You can have a look at the attached drawing for better understanding! Thank you very much! Have a good day! (defun c:ES (/ ss) if (setq ss (ssget "_:L" '((0 . "TEXT") (40 . 1.5688)))) (command "_.erase" ss"") (princ) ) (defun c:TE (/ ss) if (setq ss (ssget "_:L" '((0 . "TEXT") (40 . 2.4)))) (command "_.erase" ss"") (princ) ) TEXTHEIGHTSELECTION.dwg Quote
Steven P Posted August 25, 2022 Posted August 25, 2022 It worked OK for just testing it, though I think it will fail if the text height isn't exactly what it is looking for - you'll need a fuzz factor Someone will be able to help out with that, not something I do much 1 Quote
stlo Posted August 25, 2022 Author Posted August 25, 2022 Thanks Steven P! I think of an other option, how would I code, select text if it contain the word "SEAM"? Quote
TemporaryCAD Posted August 25, 2022 Posted August 25, 2022 Just now, stlo said: Thanks Steven P! I think of an other option, how would I code, select text if it contain the word "SEAM"? Use getss just like you are, but create a loop (use sslength to get the size) and search the contents of the text for the string "SEAM". You can use wcmatch or vl-string-search to see if the string is contained. Likewise, you can use the same strategy - looping through the selection set - to check the text height and locate ones within a range (the fuzz factor mentioned earlier). Quote
mhupp Posted August 25, 2022 Posted August 25, 2022 (edited) 38 minutes ago, stlo said: Thanks Steven P! I think of an other option, how would I code, select text if it contain the word "SEAM"? (if (setq ss (ssget "_:L" '((0 . "TEXT") (1 . "SEAM"))))) ;TEXT THAT IS ONLY SEAM "STEM" (if (setq ss (ssget "_:L" '((0 . "TEXT") (1 . "*SEAM*"))))) ;TEXT THAT HAS SEAM IN IT "123STEM123" (if (setq ss (ssget "_:L" '((0 . "TEXT") (1 . "SEAM*"))))) ;TEXT THAT STARTS WITH SEAM "SEAM123" (if (setq ss (ssget "_:L" '((0 . "TEXT") (1 . "*SEAM"))))) ;TEXT THAT ENDS WITH SEAM "123SEAM" Edited August 25, 2022 by mhupp Quote
ronjonp Posted August 25, 2022 Posted August 25, 2022 1 hour ago, stlo said: Hi everyone! I have 2 smalls codes that does exactly the same thing but for different text heights. We select all elements in a drawing, it finds all text elements with a certain height and it deletes it! The c:TE code works perfectly , the text height is 2.4. I'm having a problem with the c:ES one, the height is set to 1.5688 but it's not detecting those specific text elements? Is it because it's a roundup height number? If yes, how can I know the exact height of this specific text? You can have a look at the attached drawing for better understanding! Thank you very much! Have a good day! (defun c:ES (/ ss) if (setq ss (ssget "_:L" '((0 . "TEXT") (40 . 1.5688)))) (command "_.erase" ss"") (princ) ) (defun c:TE (/ ss) if (setq ss (ssget "_:L" '((0 . "TEXT") (40 . 2.4)))) (command "_.erase" ss"") (princ) ) TEXTHEIGHTSELECTION.dwg 98.56 kB · 0 downloads Not sure how that code is working since it's missing parenthesis . Give this fuzzy filter a try: (defun c:es (/ ss) (if (setq ss (ssget "_:L" '((0 . "TEXT") ;; Filter text height between 1.568 and 1.569 (-4 . "<AND") (-4 . ">=") (40 . 1.568) (-4 . "<=") (40 . 1.569) (-4 . "AND>") ) ) ) (command "_.erase" ss "") ) (princ) ) Quote
stlo Posted August 25, 2022 Author Posted August 25, 2022 Thanks guys! mhupp, this solution is perfect for me, meaning it's the simpliest one!! Is there a document somewhere explaining all these details? For example, (0. "TEXT") 0=? (1. "SEAM") 1=? etc... 2,3,4? Quote
mhupp Posted August 25, 2022 Posted August 25, 2022 (edited) https://www.afralisp.net/reference/dxf-group-codes.php http://docs.autodesk.com/ACD/2014/ENU/index.html?url=files/GUID-62E5383D-8A14-47B4-BFC4-35824CAE8363.htm,topicNumber=d30e678406 Use this on entity's in your drawing to see their codes. ;;----------------------------------------------------------------------------;; ;; Dump all DXF Group Data (defun C:DumpIt (/ ent) (while (setq ent (car (entsel "\nSelect Entity to Dump"))) (mapcar 'print (entget ent '( "*"))) ) (textscr) (princ) ) Will output something like this : DUMPIT Select Entity to Dump (-1 . <Entity name: 58c26d50>) (0 . "TEXT") (5 . "27081") (330 . <Entity name: 76dcfc50>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "Laser_Engrave") (370 . -1) (100 . "AcDbText") (10 36.4035806973546 -37.4216521303144 0.0) (40 . 0.125) (1 . "SEAM IS MY NAMEO") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Standard") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 0) Edited August 25, 2022 by mhupp Quote
stlo Posted August 25, 2022 Author Posted August 25, 2022 Hi ronjonp! It works perfectly! I'm learning so much! Is there a way to know the true value of the height without having a fuzz filter? Thanks guys! Quote
ronjonp Posted August 25, 2022 Posted August 25, 2022 1 hour ago, stlo said: Hi ronjonp! It works perfectly! I'm learning so much! Is there a way to know the true value of the height without having a fuzz filter? Thanks guys! Generally when working with real numbers you have to set some sort of tolerance. This is usually achieved with the EQUAL function. If you want to see more precision use (RTOS NUMBER 2 16). Quote
stlo Posted August 25, 2022 Author Posted August 25, 2022 Thanks ronjonp! Very interesting! Have a good day! Quote
ronjonp Posted August 25, 2022 Posted August 25, 2022 Just now, stlo said: Thanks ronjonp! Very interesting! Have a good day! Quote
Steven P Posted August 25, 2022 Posted August 25, 2022 2 hours ago, ronjonp said: Not sure how that code is working since it's missing parenthesis . .. but it did! how odd. It is a shame you can't just do something apply a function to the ssget criteria like (40. (round 1.5688) ) if that makes sense, 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.