tazzzz 发表于 2022-7-5 15:57:25

Lisp询问copi的编号

大家好,
我有一个lisp,可以让你选择要打印的视图,然后继续打印。
我希望在这个lisp(选择视图后)能够输入副本的数量。
谢谢你的帮助

;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)
)

ronjonp 发表于 2022-7-5 16:02:36

试试这个:
(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)
          )
    )
   (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)
)

rlx 发表于 2022-7-5 16:08:04

更多信息:https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/number-of-copies-to-plot/td-p/901242
 
gr.Rlx

Grrr 发表于 2022-7-5 16:15:42

大家不要忘记,有一个“视图”符号表,它可能更快地迭代+它将跳过activex的使用。

tazzzz 发表于 2022-7-5 16:18:29

ronjorp,
谢谢你的快速回复。
你的解决方案没有像我想的那样有效。
这个lisp仍然只打印一个副本,而不要求打印数字a副本。
我还将附上lisp的第二部分,该部分将从视图中创建列表。
希望它会更有意义。
谢谢
 

;;Created by Lee Mac
;; bit - 1=allow multiple; 2=return indexes
;; Returns: 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

ronjonp 发表于 2022-7-5 16:23:53

不知道该告诉你什么。。这部分代码将在您从列表中选择视图后提示您输入副本。
(cond ((getint "\nNumber of copies :"))
          (1)
    )

Grrr 发表于 2022-7-5 16:30:27

@ronjonp,可能会在命令调用中增加“name”参数,如:
 
(strcat view "_" (itoa (setq n (1- n))))

ronjonp 发表于 2022-7-5 16:34:39

我认为这会打破它,因为这些名字不存在?
 
更新了上面的代码以打印到命令行打印进度:
(print (strcat "Printing copy " (itoa (setq n (1+ n))) " of " (itoa i)))

Grrr 发表于 2022-7-5 16:37:52

 
啊,你说得对,对不起-我以为PLOT命令需要plotfile的名称,他们正在覆盖现有的plotfile。
 
那么也许:
 
(vlax-put (vla-get-Plot (vla-get-ActiveDocument (vlax-get-acad-object))) 'NumberOfCopies n)

tazzzz 发表于 2022-7-5 16:46:33

ronjonp,Grrr
 
除了输入上的错误列表和仍然不要求副本数量(默认情况下只取一份)之外,没有其他更改。
谢谢
页: [1] 2
查看完整版本: Lisp询问copi的编号