K Bizzy
K Bizzy

Reputation: 85

Convert dwg to pdf on AutoCAD

Hi how can I Plot to Pdf my AutoCAD drawing using VBA? I Tried

Sub PlotToPdf()
ThisDrawing.ActiveLayout.ConfigName = "DWF6 ePlot.pc3"
Dim plotFileName As String
plotFileName = "Z:\USERS\KweziM\PROJECT S\MyPlot.pdf"

Dim result As Boolean

result = ThisDrawing.Plot.PlotToFile(plotFileName)
End Sub

But this does not work.

Upvotes: 0

Views: 4207

Answers (2)

braX
braX

Reputation: 11735

That last line should be a subroutine call, not a function call... it should look like this

ThisDrawing.Plot.PlotToFile plotFileName

You do not need the result variable.

Upvotes: 1

CAD Developer
CAD Developer

Reputation: 1697

try this:

Public Sub VBAplot()
    Dim currentplot As AcadPlot
    Set currentplot = ThisDrawing.Plot

    ThisDrawing.ActiveLayout.ConfigName = "PDFCreator" ' Your plot device.
    ThisDrawing.ActiveLayout.CanonicalMediaName = "A4"

    ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
    ThisDrawing.Application.ZoomExtents
    currentplot.PlotToDevice


End Sub

Upvotes: 0

Related Questions