I'd basically like to include something like this, but not exactly sure how. Basically what i want to do is take the script at the bottom and make it so that when it saves the PDF it actually saves it as FileName + Revision.pdf (or if the revision is - or blank) just the filename.
Dim swCustPrpMgr As SolidWorks.Interop.sldworks.CustomPropertyManager swCustPrpMgr = swModel.Extension.CustomPropertyManager(
"")
Dim rev As String
swCustPrpMgr.Get3(
"Revision", False, "", rev)
If rev = "-" Then
rev =
""
Else
rev =
"_" + rev
End If
into the following BATCH PDF file: Imports SolidWorks.Interop.sldworks Imports SolidWorks.Interop.swconst Imports System Imports System.IO Imports System.Windows.Forms Partial Class SolidWorksMacro Public Sub main() Dim Drawing As ModelDoc2 = Nothing Dim longstatus As Integer = 0 Dim longwarnings As Integer = 0 Dim FileToOpen As String Dim SourcePath As String 'show a folder browser dialog to the user Dim FolderDia As New FolderBrowserDialog FolderDia.Description = "Select a folder to process" Dim diaRes As DialogResult = FolderDia.ShowDialog 'if the user clicks anything other than OK, exit If Not diaRes = DialogResult.OK Then Exit Sub End If 'source path is the folder the user selected SourcePath = FolderDia.SelectedPath 'use DirectoryInfo to get all drawing files in the selected folder Dim SourceDir As New DirectoryInfo(SourcePath) Dim sourceFiles() As FileInfo sourceFiles = SourceDir.GetFiles( "*.SLDDRW") 'loop through all drawing files in the sourceFiles array For Each DrawingFile As FileInfo In sourceFiles FileToOpen = DrawingFile.FullName 'simple SolidWorks call to open a file Drawing = swApp.OpenDoc(FileToOpen, swDocumentTypes_e.swDocDRAWING) Dim SaveAsPDFName As String SafeAsPDFName = FileToOpen + rev 'change the file extension to PDF Dim PDFName As String PDFName = IO.Path.ChangeExtension(SaveAsPDFName, ".PDF") 'create the PDF and close the drawing Dim ret As Boolean = Drawing.Extension.SaveAs(PDFName, 0, 0, Nothing, longstatus, longwarnings) swApp.CloseDoc(FileToOpen) Next End Sub Public swApp As SldWorks End Class
