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.
|