I added a Sub call in the filename function:
Function GetPDFFileName(dDoc As DrawingDocument) As String
Dim FileName As String = System.IO.Path.GetDirectoryName(dDoc.FullFileName) & "\"
Dim IssueIndex As String = "Missing Reference Assembly"
Dim aDoc As AssemblyDocument = Nothing
If dDoc.ReferencedDocuments.Count > 0
aDoc = TryCast(dDoc.ReferencedDocuments.Item(1), AssemblyDocument)
If aDoc IsNot Nothing
Try
IssueIndex = aDoc.ComponentDefinition.Parameters.Item("Name").Value.ToString
Catch
IssueIndex = "Missing_Name_Parameter"
End Try
End If
End If
For Each c As Char In System.IO.Path.GetInvalidFileNameChars()
IssueIndex = IssueIndex.Replace(c.ToString, "")
Next
If IssueIndex = String.Empty Then IssueIndex = "Trimmed_Full_Name_Parameter_Value"
If aDoc IsNot Nothing Then LogNameInNames(aDoc, IssueIndex)
FileName = String.Format("{0}{1}{2}", FileName, IssueIndex, ".pdf").ToString
Return FileName
End Function
Sub LogNameInNames(aDoc As AssemblyDocument, NameToAdd As String)
Dim ListParam As Inventor.Parameter
Try
ListParam = aDoc.ComponentDefinition.Parameters.Item("Names")
Catch
ListParam = aDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("Names", NameToAdd, UnitsTypeEnum.kTextUnits)
End Try
Dim CurrentList As IList = MultiValue.List(aDoc.DisplayName, "Names")
If Not CurrentList.Contains(NameToAdd) Then CurrentList.Add(NameToAdd)
MultiValue.List(aDoc.DisplayName, "Names") = CurrentList
End Sub
Change "Names" to whatever your list parameter name is.