VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

auto plot 10 a3 to pdf

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
dasBootik
178 Views, 3 Replies

auto plot 10 a3 to pdf

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

 

Labels (2)
3 REPLIES 3
Message 2 of 4
ed57gmc
in reply to: dasBootik

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

Message 3 of 4
dasBootik
in reply to: ed57gmc

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

Message 4 of 4
norman.yuan
in reply to: dasBootik

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report