I was given a simple task: be able to export a drawing:
1. With the Drawing Number (DwgNo in the sheet title in the bottom right, and defined as \$PRPSHEET:{DrawingNumber})
2. With the Revision Number
3. As a PDF
I have been able to satisfy the first 2 with the following code:
Option Explicit
Dim swApp As Object
Dim Part As Object
Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtention As String
Dim NewFilePath As String
Dim Rev As String
Dim DwgNo As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
FilePath = Part.GetPathName
PathSize = Strings.Len(FilePath)
Rev = Part.CustomInfo("Revision")
'DwgNo = ???
PathNoExtention = Strings.Left(FilePath, PathSize - 7)
NewFilePath = PathNoExtention & "-" & Rev & "-" & DwgNo
Part.SaveAs2 NewFilePath & ".PDF", 0, True, False
End Sub
What I have not been able to get is the Drawing Number, referenced here as DwgNo.
Any idea how I could modify my code to correctly add the Drawing Number to the file export name?##
SolidworksApi/macros