SW宏-工程图保存为 PDF

工程图保存为 PDF

宏的作用:在 SolidWorks 中打开一个文档后,自动将其保存为 .DWG.PDF 两种格式,路径与当前文档的路径相同。具体步骤如下:

  1. 获取当前打开文档的路径。
  2. 去掉原文件的扩展名。
  3. 将文档分别保存为 .DWG.PDF 文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Dim swApp As Object
Dim Part As Object
Dim Filename As String
Dim No As Integer
Dim Title As String

Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Filename = Part.GetPathName()
No = Len(Filename)
Filename = Left(Filename, No - 7)
Part.SaveAs2 Filename & ".DWG", 0, True, False
Part.SaveAs2 Filename & ".PDF", 0, True, False
End Sub
Licensed under CC BY-NC-SA 4.0