auto plot 10 a3 to pdf

auto plot 10 a3 to pdf

dasBootik
Explorer Explorer
388 Views
3 Replies
Message 1 of 4

auto plot 10 a3 to pdf

dasBootik
Explorer
Explorer

hi all i`m created code with vba to export 10 sheets from model to pdf`s but everytimes had error with line 

result = ThisDrawing.Plot.PlotToFile(plotFileName)

can you help me to solve problem? 

Sub PlotMultipleSheetsByPoints()
    Dim Layout As AcadLayout
    Dim pt1(0 To 1) As Double
    Dim pt2(0 To 1) As Double
    Dim plotFileName As String
    Dim i As Integer
    Dim OffsetX As Double
    Dim result As Boolean

    Set Layout = ThisDrawing.ActiveLayout

    Layout.RefreshPlotDeviceInfo
    Layout.ConfigName = "DWG to PDF.pc3"
    Layout.CanonicalMediaName = "ISO_full_bleed_A3_(420.00_x_297.00_MM)"
    Layout.CenterPlot = True
    Layout.PlotRotation = ac0degrees
    Layout.StandardScale = asScaleToFit
    Layout.StyleSheet = "acad.ctb"
    Layout.PlotType = acWindow

    ' based coords
    pt1(1) = 0#  ' Y1
    pt2(1) = 297#  ' Y2
    OffsetX = 420#  ' weigh sheets

    ' plot 10 sheets
    For i = 1 To 10
        plotFileName = "C:\Users\user\Desktop\autoPDF\" & i & ".pdf"

        ' offset for every sheets
        pt1(0) = (i - 1) * OffsetX  ' X1
        pt2(0) = pt1(0) + OffsetX + 50 ' X2

        ' set window to plot
        Layout.SetWindowToPlot pt1, pt2

        ' regen and plot
        ThisDrawing.Regen acAllViewports
        result = ThisDrawing.Plot.PlotToFile(plotFileName)
               
    Next i
End Sub

 

0 Likes
Accepted solutions (1)
389 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor

Have you stepped through the code to see if all the variables are being set as expected? Is the file path really "C:\Users\user\Desktop\autoPDF"? I assume the 'user' is properly set to your profile name?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 4

dasBootik
Explorer
Explorer

yeah, this pc have user name - user. 
I changed this to

plotFileName = "D:\autopdf\" & i & ".pdf"

and this still don`t working. I also forgot to add scrin error

 Без імені.png

and after click debug

 Без імені2.png

0 Likes
Message 4 of 4

norman.yuan
Mentor
Mentor
Accepted solution

Sorry accidently clicked "Accept Solution" button.

 

You may want to try to disable background plotting by setting "BackgroundPlot" system variable to 0 (and restore it back after your coded plotting.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes