RMateus Posted May 4, 2012 Share Posted May 4, 2012 Dear friends, I would like to learn how can I count the number of texts (strings) in a drawing using autolisp? Best regards. Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 4, 2012 Share Posted May 4, 2012 (edited) Do you want to also filter them by a criteria? I mean: color, layer, content... To count all text entities: (if (setq ssText (ssget "_X" '((0 . "TEXT")))) (alert (strcat "This drawing contains " (itoa (sslength ssText)) " text entities.")) ) This will include mtext in selection: (if (setq ssText (ssget "_X" '((0 . "*TEXT")))) (alert (strcat "This drawing contains " (itoa (sslength ssText)) " text/mtext entities.")) ) Edited May 4, 2012 by MSasu Fixed code example Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 4, 2012 Share Posted May 4, 2012 Would this help? http://lee-mac.com/tcount.html Quote Link to comment Share on other sites More sharing options...
RMateus Posted May 4, 2012 Author Share Posted May 4, 2012 Thanks for the quick response. I must have done something stupid. The AutoCAD gives an error "error: bad SSGET list" What is wrong with this code? (defun c:ntxt ()[font="] (if (setq ssText (ssget "_X" '((0 . "*TEXT"))))[/font] [font="] (alert "This drawing contains " (strcat (itoa (sslength ssText)) " text/mtext entities."))[/font] [font="])[/font] [font="])[/font] Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 4, 2012 Share Posted May 4, 2012 (alert (strcat "This drawing contains " (itoa (sslength ssText)) " text/mtext entities.") Besides that , localize variables .. (defun c:ntxt (/ ssText) Quote Link to comment Share on other sites More sharing options...
RMateus Posted May 4, 2012 Author Share Posted May 4, 2012 Thanks Lee. It's really good, but what I wanted to learn, is how build code as you and these are small steps that help me understand how this works. I hope don't bother you with same stupid questions in future. Best regards. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 4, 2012 Share Posted May 4, 2012 Thanks Lee.It's really good, but what I wanted to learn, is how build code as you and these are small steps that help me understand how this works. Not a problem, I admire your willingness to learn. I hope don't bother you with same stupid questions in future. Ask as many questions as you need for your understanding! Quote Link to comment Share on other sites More sharing options...
RMateus Posted May 4, 2012 Author Share Posted May 4, 2012 Ok. Thank you. Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 4, 2012 Share Posted May 4, 2012 @RMateus: I edited the counting report after pasted the code and thus the error. I have fixed my example now. Sorry for inconvenience! Quote Link to comment Share on other sites More sharing options...
CristianG Posted February 17, 2014 Share Posted February 17, 2014 Dear Friends, I will like to download a lisp routine of a command that provides me the same functions of tcount instead of counting number counts in alphabetical order Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 18, 2014 Share Posted February 18, 2014 CristianG do you want to know how many start with A or just a list in alphabetical order ? (defun c:ntxt ()[font="] (if (setq ssText (ssget "_X" '((0 . "*TEXT")(1 . "A*"))))[/font] [font="] (alert "This drawing contains " (strcat (itoa (sslength ssText)) " text/mtext entities."))[/font] [font="])[/font] [font="])[/font] Quote Link to comment Share on other sites More sharing options...
CristianG Posted February 18, 2014 Share Posted February 18, 2014 Just a list in alphabetical order ? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 19, 2014 Share Posted February 19, 2014 If you make the selection into a list then its just (VL-SORT List) Quote Link to comment Share on other sites More sharing options...
MSasu Posted February 19, 2014 Share Posted February 19, 2014 Or even easier, check ACAD_STRLSORT function - it will not required defining the sorting function, but must validate that the argument isn't nil. 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.