ruksi Posted October 14, 2009 Author Posted October 14, 2009 Just felt like playing (not case sensitive)... (defun c:Test (/ #Search #SS #List) (cond ((and (not (eq "" (setq #Search (getstring T "\nSearch string: ")))) (setq #SS (ssget "_X" '((0 . "TEXT,MTEXT") (410 . "MODEL")))) ) ;_ and (vlax-for x (setq #SS (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)) ) ;_ vla-get-activeselectionset ) ;_ setq (if (wcmatch (strcase (vla-get-textstring x)) (strcase #Search)) (setq #List (cons (strcat (vla-get-objectname x) " - " (vl-princ-to-string (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint x)) ) ;_ vlax-safearray->list ) ;_ vl-princ-to-string ) ;_ strcat #List ) ;_ cons ) ;_ setq ) ;_ if ) ;_ vlax-for (vla-delete #SS) (AT:WriteToFile "c:\\StringCount.txt" (cons (strcat (itoa (length #List)) " TEXT OBJECTS MATCHING: " #Search) #List ) ;_ cons T ) ;_ AT:WriteToFile (startapp "notepad" "c:\\StringCount.txt") ) ) ;_ cond (princ) ) ;_ defun You'll need this subroutine: ;;; Write list to file ;;; #File - file to write list to (must be in form "c:\\File.txt") ;;; #ListToWrite - list to write to file ;;; #Overwrite - If T, will overwrite; nil to append ;;; Alan J. Thompson, 04.28.09 (defun AT:WriteToFile (#File #ListToWrite #Overwrite / #FileOpen) (cond ((and (vl-consp #ListToWrite) (setq #FileOpen (open #File (if #Overwrite "W" "A" ) ;_ if ) ;_ open ) ;_ setq ) ;_ and (foreach x #ListToWrite (write-line x #FileOpen) ) ;_ foreach (close #FileOpen) T ) ) ;_ cond ) ;_ defun I checked this but it say some error Like this "Command: TEST Search string: 4mb15 ; error: no function definition: VLAX-GET-ACAD-OBJECT" I load this as nomal lisp application. if this wrong Please tell me how to do this Thanks for this:thumbsup: Quote
CarlB Posted October 14, 2009 Posted October 14, 2009 before running the routine, type the following on command line, including parentheses. It should prevent that error. (vl-load-com) Quote
alanjt Posted October 14, 2009 Posted October 14, 2009 Still not work Then you are not copying everything. I have (vl-load-com) in my startup, so I never think about adding it. Just paste both routines in a lsp file with (vl-load-com) and load it. It works. Quote
ruksi Posted October 15, 2009 Author Posted October 15, 2009 Alanjt, Please tell me step by step how todo this after or befor i have to paste. I have poor knowledge in Lisp.I like to study this Quote
alanjt Posted October 15, 2009 Posted October 15, 2009 Alanjt, Please tell me step by step how todo this after or befor i have to paste. I have poor knowledge in Lisp.I like to study this Give this a look in the meantime, but I'll explain in the morning. Right now, I'm going to bed... http://www.cadtutor.net/faq/questions/28/How+do+I+use+an+AutoLISP+routine%3F 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.