在AutoCAD上将dwg转换为pdf

时间:2017-11-22 13:06:02

标签: vba autocad

您如何使用VBA绘制我的AutoCAD绘图?我试过

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

但这不起作用。

2 个答案:

答案 0 :(得分:1)

最后一行应该是子程序调用,而不是函数调用......它应该看起来像这样

ThisDrawing.Plot.PlotToFile plotFileName

您不需要result变量。

答案 1 :(得分:0)

试试这个:

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