我想将 DWG 文件从 Excel VBA 打印为 PDF。 AutoCAD 有很多帮助,但 NanoCAD 的帮助很少或根本没有。我尝试使用等效函数,但结果出错。
我所探索的一些背景知识。
打印在 NanoCAd 中创建的配置 DWG2PDF.pc3 和以下代码:
Dim NCAD As nanocad.Application
Dim ndg As nanocad.Document
Dim pth As String
Dim result As String
pth = ThisWorkbook.Path
Set NCAD = GetObject("", "nanoCAD.Application")
NCAD.Visible = True
Set ndg = NCAD.Documents.Open(pth & "\typicals\Title-OPA01.dwg")
ndg.ActiveLayout.ConfigName = "DWG2PDF.pc3"
result = ndg.Plot.PlotToFile(pth & "\Output\op.pdf")
我使用的是autoCAD专业版指定的命令,而不是LT。 AutoCAD LT 中是否有可以适应 NanoCAD 的解决方法?
第二次试用Acrobat的打印功能,Windows要求打印为PDF。从 Internet 获取有关调用 Shell 命令的帮助。我使用了如下代码。
调用 Shell ("C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe /p/h" & pth & " ypicals\Title-OPA01.dwg")
注:我在VBA项目中引用了NanoCAD、Acrobat的类型库。
使用这一项工作给我:
Public Sub test()
Dim NCAD
Dim ndg
Dim pth As String
Dim result As String
pth = "C:\Users\Cci\Desktop\TMP\"
Set NCAD = GetObject("", "nanoCAD.Application")
NCAD.Visible = True
Set ndg = NCAD.Documents.Open(pth & "BASE CAVALLETTO.dwg")
'setup plot
ndg.ActiveLayout.RefreshPlotDeviceInfo
ndg.ActiveLayout.ConfigName = "doPDF 10"
ndg.ActiveLayout.PlotRotation = ac0degrees
ndg.ActiveLayout.StyleSheet = "monochrome.ctb"
ndg.ActiveLayout.PlotWithPlotStyles = True
ndg.ActiveLayout.PlotViewportBorders = False
ndg.ActiveLayout.PlotViewportsFirst = True
ndg.ActiveLayout.CanonicalMediaName = "A3"
ndg.ActiveLayout.PaperUnits = acMillimeters
ndg.ActiveLayout.StandardScale = acScaleToFit
ndg.ActiveLayout.ShowPlotStyles = False
ndg.ActiveLayout.CenterPlot = True
ndg.Plot.NumberOfCopies = 1
result = ndg.Plot.PlotToDevice
End Sub
doPDF 10 是一款模拟打印机并制作 pdf 文件的免费程序。
尝试根据您的目的调整此基本代码 再见
我对 CADHOBBY IntelliCAD 为爱好者提供的功能感到惊讶。它价格实惠、易于使用,并且拥有创建令人惊叹的 3D 设计所需的所有工具。