tazzzz Posted October 4, 2017 Posted October 4, 2017 Hello all, I have this lisp that will let you select what views you would like to print and proceed to print them. I would like in this lisp( after selecting the views) to be able to input the number of copies. Thanks for the help ;created by Lee Mac (defun c:plot18X24 ( / acobj acdoc views view_list listbox) (vl-load-com) (setq acobj (vlax-get-acad-object) acdoc (vla-get-activedocument acobj) views (vla-get-views acdoc) ) (vlax-for view views (setq view_list (cons (vla-get-name view) view_list)) ) (foreach view (LM:listbox "Select views to plot" view_list 1) (command "_plot" "_y" "Model" "HP.pc3" "18X24 (landscape)" "Inches" "Landscape" "No" "View" view "Fit" "Center" "Yes" "baw.ctb" "Yes" "A" "No" "No" "Yes" ) ) (princ) ) Quote
ronjonp Posted October 4, 2017 Posted October 4, 2017 (edited) Try this: (defun c:plot18x24 (/ i n vws) (vl-load-com) (vlax-for view (vla-get-views (vla-get-activedocument (vlax-get-acad-object))) (setq vws (cons (vla-get-name view) vws)) ) (setq n 0) (if (setq vws (lm:listbox "Select views to plot" vws 1)) (repeat (setq i (cond ((getint "\nNumber of copies [1]:")) (1) ) ) (print (strcat "Printing copy " (itoa (setq n (1+ n))) " of " (itoa i))) (foreach view vws (command "_plot" "_y" "Model" "HP.pc3" "18X24 (landscape)" "Inches" "Landscape" "No" "View" view "Fit" "Center" "Yes" "baw.ctb" "Yes" "A" "No" "No" "Yes" ) ) ) ) (princ) ) Edited October 5, 2017 by ronjonp Quote
rlx Posted October 4, 2017 Posted October 4, 2017 some more info : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/number-of-copies-to-plot/td-p/901242 gr.Rlx Quote
Grrr Posted October 4, 2017 Posted October 4, 2017 Guys don't forget that theres a "VIEW" symbol table, which might be faster to iterate + it would skip the usage of activex. Quote
tazzzz Posted October 4, 2017 Author Posted October 4, 2017 ronjorp, Thanks for the quick reply. Your solution doesn't work as I would like to. This lisp still prints only one copy without asking for a number a copies to be printed. I will attach also the second part of the lisp that will create the list from views. Hope it will make more sens. Thanks ;;Created by Lee Mac ;; bit - [int] 1=allow multiple; 2=return indexes ;; Returns: [lst] List of selected items/indexes, else nil (defun LM:listbox ( msg lst bit / dch des tmp rtn ) (cond ( (not (and (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq des (open tmp "w")) (write-line (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select=" (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}" ) des ) (not (close des)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) (prompt "\nError Loading List Box Dialog.") ) ( t (start_list "list") (foreach itm lst (add_list itm)) (end_list) (setq rtn (set_tile "list" "0")) (action_tile "list" "(setq rtn $value)") (setq rtn (if (= 1 (start_dialog)) (if (= 2 (logand 2 bit)) (read (strcat "(" rtn ")")) (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")"))) ) ) ) ) ) (if (< 0 dch) (unload_dialog dch) ) (if (and tmp (setq tmp (findfile tmp))) (vl-file-delete tmp) ) rtn Quote
ronjonp Posted October 4, 2017 Posted October 4, 2017 Not sure what to tell you .. this portion of the code will prompt for copies after you've selected the views from the list. (cond ((getint "\nNumber of copies [1]:")) (1) ) Quote
Grrr Posted October 4, 2017 Posted October 4, 2017 @ronjonp, perhaps increment the "name" argument inside the command-call like: (strcat view "_" (itoa (setq n (1- n)))) Quote
ronjonp Posted October 4, 2017 Posted October 4, 2017 I would think that would break it since those names don't exist? Updated code above to print to command line progress of prints: (print (strcat "Printing copy " (itoa (setq n (1+ n))) " of " (itoa i))) Quote
Grrr Posted October 4, 2017 Posted October 4, 2017 I would think that would break it since those names don't exist? Ah you are right, sorry - I thought that the PLOT command required a name for the plotfile, and they were overwriting the existing plotfile. Maybe then: (vlax-put (vla-get-Plot (vla-get-ActiveDocument (vlax-get-acad-object))) 'NumberOfCopies n) Quote
tazzzz Posted October 4, 2017 Author Posted October 4, 2017 ronjonp, Grrr There are no changes other than wrong list on input and still not asking for number of copies (takes one copy by default). Thanks Quote
ronjonp Posted October 5, 2017 Posted October 5, 2017 ronjonp, Grrr There are no changes other than wrong list on input and still not asking for number of copies (takes one copy by default). Thanks Are you using the latest code? I've modified since the first post. Other than that don't know what to tell you .. works here. What does this do when you run it? (defun c:test (/ i n) (setq n 0) (repeat (setq i (cond ((getint "\nNumber of copies [1]:")) (1) ) ) (alert (itoa (setq n (1+ n)))) ) (princ) ) Quote
tazzzz Posted October 5, 2017 Author Posted October 5, 2017 ronjonp, Thanks a lot. It worked. It was a stupid parenthesis I forgot to close. Quote
ronjonp Posted October 5, 2017 Posted October 5, 2017 ronjonp,Thanks a lot. It worked. It was a stupid parenthesis I forgot to close. Good deal 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.