nickrakker Posted April 3, 2009 Posted April 3, 2009 Can anyone help me? using acad2000i I'm using qselect to count certain "textstrings" "piece names" in my drawings ie: pc1, pc2,etc after starting qselect i have to apply al these filters clicking all the following applyto,(entire drawing) objecttype,(text) properties,(contents) operator, (=equals) value, (here manual input by user) I would like to shorten this sequence to save time thanks nick Quote
Lee Mac Posted April 3, 2009 Posted April 3, 2009 Try this, (case-sensitive): (defun c:tcnt (/ ss tStr) (if (and (setq ss (ssget "X" (list (cons 0 "*TEXT")))) (setq tStr (getstring t "\nText to Search For: "))) (progn (setq ss (vl-remove-if-not '(lambda (x) (eq tStr (cdr (assoc 1 (entget x))))) (mapcar 'cadr (ssnamex ss)))) (if (not (zerop (length ss))) (princ (strcat (rtos (length ss) 2 0) " Item(s) Found.")) (princ "\nNo Matching Text Strings. "))) (princ "\n<!> No Text Found in Drawing <!>")) (princ)) Quote
nickrakker Posted April 7, 2009 Author Posted April 7, 2009 To:Lee Mac Tried your lisp it works great thanks a lot!!!! Quote
Lee Mac Posted April 7, 2009 Posted April 7, 2009 To:Lee Mac Tried your lisp it works great thanks a lot!!!! No Probs mate - happy to have helped Quote
David Bethel Posted April 7, 2009 Posted April 7, 2009 You can use a simple ( ssget ) filter as well. [b][color=BLACK]([/color][/b]defun c:stext [b][color=FUCHSIA]([/color][/b]/ ts ss[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq ts [b][color=NAVY]([/color][/b]getstring t [color=#2f4f4f]"\nText To Search For [b][color=MAROON]([/color][/b] Case Sensitive [b][color=MAROON])[/color][/b]: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"*TEXT"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 1 ts[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"\n"[/color] [b][color=GREEN]([/color][/b]rtos [b][color=BLUE]([/color][/b]sslength ss[b][color=BLUE])[/color][/b] 2 0[b][color=GREEN])[/color][/b] [color=#2f4f4f]" - Entities Found"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote
Lee Mac Posted April 7, 2009 Posted April 7, 2009 Haha - why do I always go for the harder way around things... Nice code David 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.