明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1536|回复: 4

最新问题!

[复制链接]
发表于 2005-12-7 08:35 | 显示全部楼层 |阅读模式

各位大侠,上次请都各位高手知道用如下方法得到打印机

;;; Get plotting device list
(defun get_printers ()
  (setq _layout (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) 0))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-GetPlotDeviceNames _layout)
    )
  )
)

现在不知如何得到和要印机相配套的打印纸的格式,请帮忙指点一下,我对上面那个程式也不是很懂

发表于 2005-12-7 11:33 | 显示全部楼层
 楼主| 发表于 2005-12-7 12:51 | 显示全部楼层
楼上这位大侠,上面的进不去也,能否告诉我直接用什么方法.
发表于 2005-12-7 14:12 | 显示全部楼层

 art of the page
 
 Re: Visual Lisp Routines  --- Daron

Let's see if this will help you understand:
(defun c:Setup (/ LayoutObj Rotation TypePlot
PrinterList Name StyleTables PenStyle
PaperSizes Paper
)

(setq LayoutObj (vla-get-ActiveLayout
(vla-get-ActiveDocument
(vlax-get-acad-Object)
)
)
Rotation (vla-get-PlotRotation LayoutObj)
TypePlot (vla-get-PlotType LayoutObj)
;alldocs (vla-get-documents (vlax-get-acad-object))
)
;Sets correct printer
(vla-RefreshPlotDeviceInfo LayoutObj)
(setq PrinterList
(vlax-safearray->list
(vlax-variant-value
(vla-getPlotDeviceNames LayoutObj)
)
)
)
;(vlax-for each-dwg alldocs
;(setq LayoutObj (vla-get-Layouts each-dwg))
(foreach name PrinterList
;(setq var (vla-GetPlotDeviceNames name))
(if (= name "PDF - Adobe Acrobat Distiller.pc3")
(vla-put-ConfigName
LayoutObj
"PDF - Adobe Acrobat Distiller.pc3"
)
)
)
;)
;Sets correct Pen Style
(setq StyleTables
(vlax-safearray->list
(vlax-variant-value
(vla-GetPlotStyleTableNames LayoutObj)
)
)
)
(foreach penstyle StyleTables
(if (= penstyle "PHC-Inks-Halfscale.ctb")
(vla-put-StyleSheet LayoutObj "PHC-Inks-Halfscale.ctb")
)
)
;Sets correct Paper Size
(setq PaperSizes
(vlax-safearray->list
(vlax-variant-value
(vla-GetCanonicalMediaNames LayoutObj)
)
)
)
(foreach Paper PaperSizes
(if (= Paper "Letter")
(vla-put-CanonicalMediaName LayoutObj "Letter")
)
)
;Sets Correct PlotType ie acLayout
(if (/= TypePlot 5)
(vla-put-PlotType LayoutObj acLayout)
)
(if (/= Rotation 0)
(vla-put-PlotRotation LayoutObj 0)
)
(vla-regen (vla-get-activedocument (vlax-get-acad-object))
acActiveViewport
)
(vlax-release-object LayoutObj)
(princ)
)
Do not use this as is. You need to look through it and find out what you have as far as printer name and paper styles and pen weights etc. and set them to your needs. This is my first run. Try inspecting a few parts of it and see what you get. It's not reactor driven, but could easily be if it's really necessary. You'll find these methods and properties in the help file I was talking about earlier. Also, I didn't tell you earlier, but you need to release all vla-objects after using them. Therefore:
(vlax-release-object objname)
See routine above. You can do what you ask, just don't use (command...) to invoke your processes. Learn VL sans reactors before learning reactors. Did you look at the link I sent you to in my first post?
Actually, the first time I learned to use reactors was from reading an article by Mr. Green. The moderator of this forum.
------------------
:D

[This message has been edited by Daron (edited May 09, 2003).]

[This message has been edited by Daron (edited May 09, 2003).]

--------------------
It's better than bad,
It's good.

 

 楼主| 发表于 2005-12-7 15:48 | 显示全部楼层

感谢楼主

这样做是可以做到但是还有一个小小的问题请教一下,如果我第次开启CAD时没有选择我设定的打印机那纸的格式没办法显示,

必须手动打印一次后才能获取到相同打印机的纸的格式;

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-5 04:12 , Processed in 0.301667 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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