ILoveMadoka 发表于 2022-7-6 09:48:54

添加“FOREACH”选项

我们得到的图纸有时使用模型空间和图纸空间
还有一些只使用其中一种。
我有一点Lisp程序(脚本),但我必须根据需要对输入/输出的行进行注释
根据图纸情况。
 
是否可以编写为用户可以选择“foreach”行?
我不知道怎么做。。。
 
这是我的。。。
 
 
(defun c:PS1 ()

(foreach tab (cons "Model" (layoutlist)) ;;For Model Space too use this!!
;(foreach tab (layoutlist)                  ;;For Paper Space only

    (setvar 'CTAB tab)
(Command "-plot" "y" "" "\\\\sc1fs1\\c01886""11x17" "i" "L" "n" "e" "f" "center" "y" "monochrome.ctb" "y" "n" "n" "n" "n" "y" "n")
(COMMAND "Zoom" "e") )
(command "qsave")
(princ))

 
谢谢

Smirnoff 发表于 2022-7-6 10:44:59

可能是这样的?
 
(defun c:ps2()
(foreach tab (cons "Model" (layoutlist))
   (setvar "CTAB" tab)
   (command "_.zoom" "_e")
   (initget 1 "Yes No")
   (if(= "Yes"(getkword "\nDo you want to plot this!? : "))
   (command "-plot" "y" "" "\\\\sc1fs1\\c01886""11x17" "i" "L" "n" "e" "f" "center" "y" "monochrome.ctb" "y" "n" "n" "n" "n" "y" "n")
   ); end if
   ); end foreach
(command "_.qsave")
(princ "\n It seems all... ")
(princ)
); end of c:ps2

rkmcswain 发表于 2022-7-6 11:16:27

像这样的怎么样?
 


(defun c:PS1 ()

(initget "A M L")
(setq ans (getkword "\nOperate on "))

(cond
   ((eq ans "A")(setq myset (cons "Model" (layoutlist))))
   ((eq ans "L")(setq myset (layoutlist)))
   ((eq ans "M")(setq myset (list "Model")))
)   

(foreach tab myset
   (setvar 'CTAB tab)
   (Command "-plot" "y" "" "\\\\sc1fs1\\c01886""11x17" "i" "L" "n" "e" "f" "center" "y" "monochrome.ctb" "y" "n" "n" "n" "n" "y" "n")
   (COMMAND "Zoom" "e")
)
(command "qsave")
(princ)
)


页: [1]
查看完整版本: 添加“FOREACH”选项