明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3761|回复: 15

[讨论] 如何获得某台打印机的纸张列表呢?(已解决)

  [复制链接]
发表于 2011-4-19 15:52:16 | 显示全部楼层 |阅读模式
本帖最后由 langjs 于 2011-4-21 08:29 编辑

lisp中,已知计算机安装的一个打印机名,如何获得这台打印机的纸张列表呢?谢谢。


最后采用的程序如下:

;;; 获得某打印机纸张类型列表
;;;例:  (setq PaperSize (GetPaperList "HP LaserJet 5000 Series PCL" ))
(defun GetPaperList (priname / acadobj canpapersizearr canpapersizelist canpapersizevar doc index layout papersize)
  (vl-load-com)
  (setq layout (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
  (vla-put-configname layout priname);将打印机设为当前打印机,下面程序是论坛某老大的获取当前打印纸张类型。
  (setq acadobj (vlax-get-acad-object)
doc (vla-get-activedocument acadobj)
layout (vla-get-activelayout doc)
  )
  (vla-RefreshPlotDeviceInfo layout)
  (setq CanPaperSizeVar (vla-GetCanonicalMediaNames layout)
CanPaperSizeArr (vlax-variant-value CanPaperSizeVar)
CanPaperSizeLIst (vlax-safearray->list CanPaperSizeArr)
PaperSize '()
index 0
  )
  (repeat (length CanPaperSizeList)
    (setq Papersize (cons (vla-GetLocaleMediaName layout (nth index CanPaperSizeList)) Papersize)
   index (1+ index)
    )
  )
  (reverse PaperSize)
)

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2024-1-23 20:12:44 | 显示全部楼层
你好,网络打印机怎么输入不了

(setq PaperSize (GetPaperList " \\192.168.0.142\左边"  ))

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2023-11-14 22:43:05 | 显示全部楼层
langjs 发表于 2011-4-21 08:30
感谢老大的帮助。谢谢

大师,最终的源码在哪里?能给下吗
发表于 2011-4-19 16:38:02 | 显示全部楼层
 楼主| 发表于 2011-4-19 18:06:00 | 显示全部楼层
楼上的网址我怎么打不开啊
 楼主| 发表于 2011-4-19 18:06:45 | 显示全部楼层
回复 Andyhon 的帖子

楼上的网址我怎么打不开啊
发表于 2011-4-19 18:22:19 | 显示全部楼层
  1. ;;04/09/04 Bill Zondlo -received from AutoDesk NG
  2. ;;programming examples to get plotter info
  3. ;;
  4. (defun get_plotter_names ()
  5. (vla-RefreshPlotDeviceInfo (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
  6. (vlax-safearray->list
  7. (vlax-variant-value
  8. (vla-getplotdevicenames
  9. (vla-get-activelayout
  10. (vla-get-activedocument
  11. (vlax-get-acad-object)))))) ;gets list of installed plotters
  12. )
  1. ;;04/09/04 Bill Zondlo -received from AutoDesk NG
  2. ;;programming examples to get plotter info
  3. ;;
  4. (defun get_paper_sizes ()
  5. (vla-RefreshPlotDeviceInfo (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
  6. (vlax-safearray->list
  7. (vlax-variant-value
  8. (vla-getCanonicalMediaNames
  9. (vla-get-activelayout
  10. (vla-get-activedocument
  11. (vlax-get-acad-object)))))) ;gets all media names
  12. )
 楼主| 发表于 2011-4-19 18:49:13 | 显示全部楼层
回复 Andyhon 的帖子

谢谢老大提供帮助,可惜不是我想要的程序。

我是自己做了一个打印DCL,里边两个打印机,对应的列表不一样,我如何做到选择其中一个打印机,就把它对应的纸张列表取出来?

网上有个程序,但是只能读取当前打印机的纸张列表,不是当前打印机的列表读不出来,和我需要的差了一点点。
;;; 获得当前打印机纸张类型列表
(defun GetPaperList ()
  (vl-load-com)
  (setq acadobj (vlax-get-acad-object)
doc (vla-get-activedocument acadobj)
layout (vla-get-activelayout doc)
  )
  (vla-RefreshPlotDeviceInfo layout)
  (setq CanPaperSizeVar (vla-GetCanonicalMediaNames layout)
CanPaperSizeArr (vlax-variant-value CanPaperSizeVar)
CanPaperSizeLIst (vlax-safearray->list CanPaperSizeArr)
PaperSize '()
index 0
  )
  (repeat (length CanPaperSizeList)
    (setq Papersize (cons (vla-GetLocaleMediaName layout (nth index CanPaperSizeList))
     Papersize
      )
   index (1+ index)
    )
  )
  (reverse PaperSize)
)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2011-4-19 21:06:35 | 显示全部楼层
Ref:

(setq ad (vla-get-activedocument (vlax-get-acad-object)))

(defun GetCanonicalMediaNames (ad)
  (vla-RefreshPlotDeviceInfo
    (vla-get-activelayout ad)
  )
  (vlax-safearray->list
    (vlax-variant-value
      (vla-GetCanonicalMediaNames
        (vla-item (vla-get-layouts ad) "Model")
      )
    )
  )
)

(defun GetLocaleMediaNames (ad / mn mnl)
  (setq la (vla-item (vla-get-layouts ad) "Model"))
  (foreach mn (GetCanonicalMediaNames ad)
    (setq mnl (cons (vla-GetLocaleMediaName la mn) mnl))
  )
  (reverse mnl)
)

;;; (GetCanonicalMediaNamesOfConfigname ad "Acrobat PDFWriter")
(defun GetCanonicalMediaNamesOfConfigname (ad cn / oldcn al cmn)
  (setq al (vla-get-ActiveLayout ad))
  (setq oldcn (vla-get-configname al))
  (vla-put-configname al cn)
  (vla-RefreshPlotDeviceInfo al)
  (setq cmn (GetCanonicalMediaNames ad))
  (if (/= oldcn "None")
    (vla-put-configname al oldcn)
  )
  cmn
)

;;; =================
info:
http://forums.autodesk.com/t5/Vi ... -Printer/m-p/884662
 楼主| 发表于 2011-4-19 21:22:30 | 显示全部楼层
本帖最后由 langjs 于 2011-4-19 22:50 编辑

老大你太强悍了,崇拜,正是我需要的!!!万分感谢啊!!!
试用一下,怎么好多列表中的元素名变成User+数字格式了?
 楼主| 发表于 2011-4-20 10:12:57 | 显示全部楼层
回复 Andyhon 的帖子

老大,我执行后返回某个打印机的结果是:(User256 User281 User280 User279 User278 User277 User276 User275 User274
User273 User272 User271 User270 User68 User67 User66 User65 User64 User63
User62 User61 User60 User59 User58 User57 User56 User55 User54 User53 User52
User51 User50 User47 User46 User45 User44 User43 User42 German Legal Fanfold
German Std Fanfold US Std Fanfold 6 3/4 Envelope Envelope Monarch Envelope
Envelope B6 Envelope B5 Envelope B4 Envelope C65 Envelope C6 Envelope C4
Envelope C3 Envelope C5 Envelope DL E size sheet D size sheet C size sheet
Envelope #14 Envelope #12 Envelope #11 Envelope #10 Envelope #9 Note 11x17
10x14 Quarto Folio B5 (JIS) B4 (JIS) A5 A4 Small A4 A3 Executive Statement
Legal Ledger Tabloid Letter Small Letter)

好多User+数字格式,我想要的结果是这样的:
( ARCH E ARCH D ARCH C ARCH B ARCH A ANSI E ANSI D ANSI C ANSI B ANSI A A1
A0 A3 Extra Transverse A3 Transverse A2 B5 (ISO) Extra A5 Extra A3 Extra B5
(JIS) Transverse A5 Transverse A4 Plus Letter Plus SuperB/SuperB/A3
SuperA/SuperA/A4 Letter Extra Transverse A4 Transverse Letter Transverse A4
Extra Tabloid Extra Legal Extra Letter Extra Envelope Invite 11x15 10x11 9x11
Japanese Postcard B4 (ISO) German Legal Fanfold German Std Fanfold US Std
Fanfold 6 3/4 Envelope Envelope Monarch Envelope Italy Envelope B6 Envelope B5
Envelope B4 Envelope C65 Envelope C6 Envelope C4 Envelope C3 Envelope C5
Envelope DL E size sheet D size sheet C size sheet Envelope #14 Envelope #12
Envelope #11 Envelope #10 Envelope #9 Note 11x17 10x14 Quarto Folio B5 (JIS) B4
(JIS) A5 A4 Small A4 A3 Executive Statement Legal Ledger Tabloid Letter Small
Letter)

请问能不能转变过来呢?谢谢
发表于 2011-4-20 10:54:42 | 显示全部楼层
未遇过您说的情况,帮不上忙呢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 23:39 , Processed in 0.207248 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表