问题
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.
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/47435510/convert-dwg-to-pdf-on-autocad