Author Topic: use vla-PlotToFile to plot dwg to pdf with acWindow plottype, but pdf is offset  (Read 1209 times)

0 Members and 1 Guest are viewing this topic.

aHero

  • Guest
I use vla-PlotToFile to plot dwg to pdf with acWindow plottype, but pdf is offset. please help, thanks
Code: [Select]
(defun c:myplot ( / )
  (vl-load-com)
  (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
  (setvar "CMDECHO" 0)
  (setvar "BLIPMODE" 0)
  (setvar "OSMODE" 0)
  ;(setvar "LAYOUTREGENCTL" 1)

  (setq lyout (vla-get-activelayout adoc))
  (setq styleSheet "monochrome.ctb")
  (setq cfgName "AutoCAD PDF (High Quality Print).pc3")
  (vla-RefreshPlotDeviceInfo lyout)
  (vla-put-ConfigName lyout CfgName)
  (vla-put-PaperUnits lyout acMillimeters)
  (vla-put-plotrotation lyout ac0degrees)
  (vla-put-PlotType lyout acWindow)
  (vla-put-CanonicalMediaName lyout "ISO_full_bleed_A3_(420.00_x_297.00_mm)")
  (vla-put-PlotWithLineweights lyout :vlax-false)
  (vla-put-PlotWithPlotStyles lyout :vlax-true)
  (vla-put-StyleSheet lyout styleSheet)
  (vla-put-CenterPlot lyout :vlax-true)
  (vla-put-plotrotation lyout ac0degrees)
 
  (vla-put-activelayout adoc lyout)
 

 
  (setq ss (ssget "X" '((0 . "INSERT") (2 . "bztk") (67 . 0))))

  (setq i -1)
  (repeat (sslength ss)
    (setq i (1+ i))
    (setq tk_ent (ssname ss i))
    (vla-GetBoundingBox (vlax-ename->vla-object tk_ent) 'minpoint 'maxpoint)
    (setq pointTemp1 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-put-element pointTemp1 0 (vlax-safearray-get-element  minpoint 0))
    (vlax-safearray-put-element pointTemp1 1 (vlax-safearray-get-element  minpoint 1))

    (setq pointTemp2 (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-put-element pointTemp2 0 (vlax-safearray-get-element maxpoint 0))
    (vlax-safearray-put-element pointTemp2 1 (vlax-safearray-get-element maxpoint 1))
    (vla-SetWindowToPlot lyout pointTemp1 pointTemp2)
    (vla-put-activelayout adoc lyout)
    (vla-PlotToFile (vla-get-Plot adoc) (strcat (getvar 'dwgprefix) "draw" (itoa i)))

  )

  (setvar "BLIPMODE" 0)
  (setvar "OSMODE" 231 )
  (setvar "CMDECHO" 1)
)

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Compare your normal printer's Paper Sizes and margins to that of the PDF. Your code may have to adjust for the differences.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D