本帖最后由 kucha007 于 2023-3-12 17:28 编辑
也可以这样改写:Flag为T时只获取自定义的纸张
- ;获取打印机纸张
- (defun K:GetPaperLst (PrintNam Flag / DOC Layout PaperLst)
- (vl-load-com)
- (defun k:Remove-NoChar (Lst Char / item NewLst)
- (setq NewLst '())
- (foreach item Lst
- (if (vl-string-search Char item)
- (setq NewLst (cons item NewLst))
- )
- )
- (reverse NewLst)
- )
- (setq DOC (vla-get-ActiveDocument (vlax-get-acad-object))
- Layout (vla-get-activeLayout DOC)
- )
- (vla-put-configname layout PrintNam) ;设置当前打印机
- (vla-RefreshPlotDeviceInfo Layout) ;更新打印机、规范介质和打印样式表信息
- (setq PaperLst (vlax-safearray->list (vlax-variant-value (vla-GetCanonicalMediaNames Layout))))
- (mapcar
- '(lambda (xx)
- (vla-GetLocaleMediaName Layout xx)
- )
- (if (= Flag T)
- (k:Remove-NoChar PaperLst "UserDefinedMetric")
- PaperLst
- )
- )
- )
|