@mitoborecek,
I replaced the filename creation with a custum function:
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
'UPDATE
InventorVb.DocumentUpdate()
'Create PDF
Call CreatePDFExport(ThisApplication.ActiveDocument)
End Sub
Private Sub CreatePDFExport(dDoc As DrawingDocument)
' Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
'Set the destination file name
oDataMedium.FileName = GetPDFFileName(dDoc)
' Get the PDF translator Add-In.
Dim PDFAddIn As TranslatorAddIn
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
' Check whether the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions(dDoc, oContext, oOptions) Then
' Options for drawings...
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Publish_All_Sheets") = 0
oOptions.Value("Launch_Viewer") = 0
oOptions.Value("Vector_Resolution") = 2400
oOptions.Value("Sheet_Range") = PrintRangeEnum.kPrintSheetRange
oOptions.Value("Custom_Begin_Sheet") = 1
oOptions.Value("Custom_End_Sheet") = 1
End If
'Publish document.
Try
Call PDFAddIn.SaveCopyAs(dDoc, oContext, oOptions, oDataMedium)
Catch ex As Exception
MessageBox.Show(ex.Message, "Export Error")
End Try
End Sub
Function GetPDFFileName(dDoc As DrawingDocument) As String
Dim FileName As String = System.IO.Path.ChangeExtension(dDoc.FullFileName, ".pdf")
Dim UserProperties As PropertySet = dDoc.PropertySets.Item("Inventor User Defined Properties")
Dim IssueIndex As String
Try
IssueIndex = UserProperties.Item("Issue Index").Value
Catch
UserProperties.Add("1", "Issue Index")
IssueIndex = UserProperties.Item("Issue Index").Value
End Try
FileName = String.Format("{0}({1}){2}", Left(FileName, FileName.Length-4), IssueIndex, Right(FileName, 4)).ToString
Return FileName
End Function
This uses an iProperty in the drawing file, and requires manual change. Didn't think you would want it to increment automatically.