Author Topic: PlottoDevice ERROR  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 495
PlottoDevice ERROR
« on: February 02, 2015, 06:18:33 AM »
I am trying to plot a window to PDF with a given File Name. But following routine gives error. Please help.

Code: [Select]
(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


roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: PlottoDevice ERROR
« Reply #1 on: February 02, 2015, 07:27:38 AM »
The PlotToDevice method applies to the plot object not the document object.

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: PlottoDevice ERROR
« Reply #2 on: February 02, 2015, 12:23:15 PM »

mailmaverick

  • Bull Frog
  • Posts: 495
Re: PlottoDevice ERROR
« Reply #3 on: February 02, 2015, 11:09:07 PM »
Thanks for your suggestion.

But as you will see that I have completed most of the program and am stuck up with a little thing.

Could you help me correct it please.




Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: PlottoDevice ERROR
« Reply #4 on: February 03, 2015, 04:12:15 AM »
The answer may be found in Lee's original code on HyperPics:
Code: [Select]
(vla-PlotToDevice (vla-get-Plot doc))
Since you already have (setq currentPlot (vla-get-Plot doc)), you can use:
Code: [Select]
(vla-PlotToDevice currentPlot)
I'm sure you could have worked this out  :wink: