I am trying to plot a window to PDF with a given File Name. But following routine gives error. Please help.
(defun c:CustomPageSetup ()
;; Source : http://hyperpics.blogs.com/beyond_the_ui/2012/06/plotting-and-page-setups-with-autolisp.html
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq plotCfgs (vla-get-PlotConfigurations doc))
(setq plotCfg (vl-catch-all-apply 'vla-Item (list plotCfgs "MYPAGESETUP")))
(if (/= (type plotCfg) 'VLA-OBJECT)
(if (= (getvar "TILEMODE") 0)
(progn (setq plotCfg (vla-Add plotCfgs "MYPAGESETUP" :vlax-false))
(setq mediaNames (vlax-variant-value (vla-GetCanonicalMediaNames (vla-item (vla-get-layouts doc) "Layout"))))
)
(progn (setq plotCfg (vla-Add plotCfgs "MYPAGESETUP" :vlax-true))
(setq mediaNames (vlax-variant-value (vla-GetCanonicalMediaNames (vla-item (vla-get-layouts doc) "Model"))))
)
)
)
(vla-RefreshPlotDeviceInfo plotCfg)
(vla-put-ConfigName plotCfg "DWG to PDF.pc3")
(vla-put-CanonicalMediaName plotCfg "ISO_A3_(297.00_x_420.00_MM)")
(vla-put-PaperUnits plotCfg acInches)
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
(setq point1 (vlax-variant-value
(vla-GetPoint (vla-get-Utility doc) nil "Click the lower-left of the window to plot.")
)
)
(setq pointTemp1 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
(vlax-safearray-put-element pointTemp1 0 (vlax-safearray-get-element point1 0))
(vlax-safearray-put-element pointTemp1 1 (vlax-safearray-get-element point1 1))
(setq point2 (vlax-variant-value
(vla-GetCorner (vla-get-Utility doc) point1 "Click the upper-right of the window to plot.")
)
)
(setq pointTemp2 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
(vlax-safearray-put-element pointTemp2 0 (vlax-safearray-get-element point2 0))
(vlax-safearray-put-element pointTemp2 1 (vlax-safearray-get-element point2 1))
(vla-put-PlotType (vla-get-ActiveLayout doc) acWindow)
(vla-SetWindowToPlot plotCfg pointTemp1 pointTemp2)
(vla-put-UseStandardScale plotCfg :vlax-true)
(vla-put-StandardScale plotCfg acScaleToFit)
(vla-put-CenterPlot plotCfg :vlax-true)
(vla-put-PlotHidden plotCfg :vlax-false)
(vla-put-PlotRotation plotCfg ac0degrees)
(vla-put-PlotViewportBorders plotCfg :vlax-false)
(vla-put-PlotViewportsFirst plotCfg :vlax-false)
(vla-put-PlotWithLineweights plotCfg :vlax-true)
(vla-put-ScaleLineweights plotCfg :vlax-false)
(vla-put-PlotWithPlotStyles plotCfg :vlax-true)
(vla-put-ShowPlotStyles plotCfg :vlax-true)
(if (= (getvar "PSTYLEMODE") 0)
(vla-put-StyleSheet plotCfg "monochrome.stb")
(vla-put-StyleSheet plotCfg "monochrome.ctb")
)
(vla-CopyFrom (vla-get-ActiveLayout doc) plotCfg)
(setq currentPlot (vla-get-Plot doc))
(setq plotFileName "d:\\MyPlot.PDF")
(vla-PlotToDevice doc)
)
The error is in last line i.e. (vla-PlotToDevice doc)
Error : ; error: ActiveX Server returned the error: unknown name: PlotToDevice
; reset after error