ketxu Posted July 18, 2011 Share Posted July 18, 2011 Hey Lee and others, I just have a problem about LM:listbox, and i can't find out what wrong, please help me. First, i wrote (copy and paste ^^) a rountine to close multi-drawing like that, call number 1 : ;1 (defun CloseSpecifiedDwg (FileName / docs doc OurDoc) (vl-load-com) (setq FileName (if (wcmatch (strcase FileName) "*.DWG") FileName (strcat FileName ".DWG")) docs (vla-get-documents (vlax-get-acad-object)) doc (vla-get-activedocument (vlax-get-acad-object)) OurDoc (vl-catch-all-apply 'vla-item (list docs 1);filename) ) ) (if (vl-catch-all-error-p OurDoc) (princ (strcat "\nCan't close " FileName " because it isn't open.")) (vla-close OurDoc :vlax-true) ) (vlax-release-object OurDoc) (vlax-release-object Doc) (vlax-release-object Docs) ) (defun LM:ListBox ( title data multiple / file tmp dch return ) ;; © Lee Mac 2011 (cond ( (not (and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w")) (write-line (strcat "listbox : dialog { label = \"" title "\"; spacer; : list_box { key = \"list\"; multiple_select = " (if multiple "true" "false") "; } spacer; ok_cancel;}" ) file ) (not (close file)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) ) ( t (start_list "list") (mapcar 'add_list data) (end_list) (setq return (set_tile "list" "0")) (action_tile "list" "(setq return $value)") (setq return (if (= 1 (start_dialog)) (mapcar '(lambda ( x ) (nth x data)) (read (strcat "(" return ")"))) ) ) ) ) (if (< 0 dch) (unload_dialog dch)) (if (setq tmp (findfile tmp)) (vl-file-delete tmp)) return ) (defun c:1 (/ docs doc indx lstname lst2Close) (vl-load-com) (grtext -1 "T\U+1EAFt b\U+1EA3n v\U+1EBD @ketxu - S\U+01A1n T\U+00F9ng") (setq docs (vla-get-documents (vlax-get-acad-object)) ;the collection of all of the currently open drawings doc (vla-get-activedocument (vlax-get-acad-object)) ;the active drawing indx 1 lstName nil ) (vlax-for dwg docs (setq lstName (append (list (strcat (itoa indx) "." (vla-get-name dwg))) lstName) indx (1+ indx)) ) (setq lst2Close (LM:listbox "T\U+1EAFt b\U+1EA3n v\U+1EBD @ketxu (Gi\U+1EEF Ctrl \U+0111\U+1EC3 ch\U+1ECDn nhi\U+1EC1u) :" (reverse lstName) T)) (foreach Name lst2Close (closeSpecifiedDwg (vl-string-left-trim (strcat (rtos (atoi Name) 2 0) ".") Name)) ) (vlax-release-object Docs) ) It's ok. But it can't close all of drawing or active drawing, so i continuous copy more code, call 2 : (defun CloseSpecifiedDwg (FileName / docs doc OurDoc) (vl-load-com) (setq FileName (if (wcmatch (strcase FileName) "*.DWG") FileName (strcat FileName ".DWG")) docs (vla-get-documents (vlax-get-acad-object)) doc (vla-get-activedocument (vlax-get-acad-object)) OurDoc (vl-catch-all-apply 'vla-item (list docs 1) ) ) (if (vl-catch-all-error-p OurDoc) (princ (strcat "\nCan't close " FileName " because it isn't open.")) (vla-close OurDoc :vlax-true) ) (vlax-release-object OurDoc) (vlax-release-object Doc) (vlax-release-object Docs) ) (defun LM:ListBox ( title data multiple / file tmp dch return ) (cond ( (not (and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w")) (write-line (strcat "listbox : dialog { label = \"" title "\"; spacer; : list_box { key = \"list\"; multiple_select = " (if multiple "true" "false") "; } spacer; ok_cancel;}" ) file ) (not (close file)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) ) ( t (start_list "list") (mapcar 'add_list data) (end_list) (setq return (set_tile "list" "0")) (action_tile "list" "(setq return $value)") (setq return (if (= 1 (start_dialog)) (mapcar '(lambda ( x ) (nth x data)) (read (strcat "(" return ")"))) ) ) ) ) (if (< 0 dch) (unload_dialog dch)) (if (setq tmp (findfile tmp)) (vl-file-delete tmp)) return ) (defun c:2 (/); docs doc indx lstname lst2Close) (vl-load-com) (grtext -1 "T\U+1EAFt b\U+1EA3n v\U+1EBD @ketxu - S\U+01A1n T\U+00F9ng") (setq docs (vla-get-documents (vlax-get-acad-object)) doc (vla-get-activedocument (vlax-get-acad-object)) indx 1 lstName nil ) (vlax-for dwg docs (setq lstName (append (list (strcat (itoa indx) "." (vla-get-name dwg))) lstName) indx (1+ indx)) ) (setq lst2Close (LM:ListBox "T\U+1EAFt b\U+1EA3n v\U+1EBD @ketxu (Gi\U+1EEF Ctrl \U+0111\U+1EC3 ch\U+1ECDn nhi\U+1EC1u) :" (reverse lstName) T)) (if (=(1+ (length lst2Close)) indx) (closeall) (progn (foreach Name lst2Close (setq N2C (vl-string-left-trim (strcat (rtos (atoi Name) 2 0) ".") Name)) (if (= N2C (getvar 'Dwgname))(close) (closeSpecifiedDwg N2C) ) ) ) ) (vlax-release-object Doc) (vlax-release-object Docs) ) (defun doc:CloseAllButActive (TrueOrFalse / cnt) (setq cnt 0) (vlax-for Item (vla-get-Documents (vlax-get-acad-object)) (if (= (vla-get-Active Item) :vlax-False) (progn (vla-close Item TrueOrFalse) (setq cnt (1+ cnt)) ) ) ) cnt ); end defun (defun close (/) ;added by cadmoogle to close the last drawing without saving (command "close" "n") (princ) ); end defun (defun closeall ( / cnt) ;Closes all drawings except active (setq cnt (doc:CloseAllButActive :vlax-True)) (if (> cnt 0) (princ (strcat "\n(" (itoa cnt) ") document" (if (> cnt 1) "s" "") " closed without saving.")) (princ "\nNo other documents to close.") ) (close) (princ) ) Defun CloseSpecifiedDwg and LM:listbox not change. But so strange, 2 didn't work when i appload 2. It alert about "too many arguments", so i'd checked and finded out it from (setq lst2Close (LM:ListBox "T\U+1EAFt b\U+1EA3n v\U+1EBD @ketxu (Gi\U+1EEF Ctrl \U+0111\U+1EC3 ch\U+1ECDn nhi\U+1EC1u) :" (reverse lstName) T)) This code line working nomarlly in 1, but it going wrong with 2:( Then, i re-open drawing, and not appload, just sequential copy all code line, it work... And more, when i have appload 2, it didn't work, so i appload 1 again, it didn't work, too, with the same error (although well done before appload 2) I don't know what wrong, maybe from vl-filename-mktemp or sth in Lee's function ??? everybody help me please Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 19, 2011 Share Posted July 19, 2011 The latest version of my ListBox function can be found here, as far as I know there are no issues with it. Use this to help determine the cause of your error. Quote Link to comment Share on other sites More sharing options...
ketxu Posted July 19, 2011 Author Share Posted July 19, 2011 Thanks Lee for reply, but when i replace new ListBox function, it still "; error: too many arguments", and when debug on last error, i only received a message alert :CALLBACK-ENTRY Please test help me Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 19, 2011 Share Posted July 19, 2011 Did you follow the tutorial correctly? Is the 'Break on Error' option set before the error occurs? Also, why have you removed all headers from my code? Quote Link to comment Share on other sites More sharing options...
ketxu Posted July 19, 2011 Author Share Posted July 19, 2011 I did. Have you tested my rountine? Oh, when i remember all arguments, i often clear all comment ^^ Srr if it make you "troublesome" Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 19, 2011 Share Posted July 19, 2011 I did. Have you tested my rountine? No, and I don't plan to. Oh, when i remember all arguments, i often clear all comment ^^ Srr if it make you "troublesome" Please read the Terms of Use applicable to all code published on my site. Quote Link to comment Share on other sites More sharing options...
ketxu Posted July 20, 2011 Author Share Posted July 20, 2011 No, and I don't plan to. Please read the Terms of Use applicable to all code published on my site. Oh, it's my error, cause i copy your code from http://www.theswamp.org/index.php?topic=37462.0, and comment as an example, so im not deliberately, i will fix it now ^^ Srr again ^^ haiza, my problem still exist. Thank you again for your attention ^^ 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.