- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been trying to make a loop for every part to import the custom excel parameters to iproperties so, for each row with that ID number I want to find the component with that occurrence Name and fill the corresponding iproperties, followed some forum ideas but the same error appear every time: GoExcel: Could not match the column title: "ID".
Sub Main
Dim AsmDoc As AssemblyDocument = ThisDoc.Document
Dim FileName As String = "File.xls"
TraverseAssembly(AsmDoc.ComponentDefinition.Occurrences,FileName)
End Sub
Sub TraverseAssembly(Occurrences As ComponentOccurrences,FileName As String)
MessageBox.Show(FileName, "Title")
' Iteration through all of the occurrence
For Each Occ As ComponentOccurrence In Occurrences
If Occ.DefinitionDocumentType = kPartDocumentObject Then
'Get document from Occurrence.
Dim OccDoc As Document = Occ.Definition.Document
'Avoid read only parts like content center/library parts.
If Not OccDoc.IsModifiable Then Continue For
'Finding the Row containing the occurrence
Dim Row As Integer = GoExcel.FindRow(FileName, "Sheet X", "ID", "=", Occ.Name)
If Row = -1 Then Continue For'MessageBox.Show("could not find row", "Title") :
Dim SummaryPropertySet As PropertySet = OccDoc.PropertySets.Item("Inventor Document Summary Information")
Dim DesignPropertySet As PropertySet = OccDoc.PropertySets.Item("Design Tracking Properties")
Dim CustomPropertySet As PropertySet = OccDoc.PropertySets.Item("Inventor User Defined Properties")
'try and set the iproperty
Try
Dim CustomProp1 As [Property] = CustomPropertySet.Item("iProperties")
CustomProp1.Value = GoExcel.CurrentRowValue("Parameters")
Catch Ex As Exception 'iproperties not found so add and set
CustomPropertySet.Add(GoExcel.CurrentRowValue("Parameters"),"iProperties")
End Try
End If
If Occ.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(Occ.SubOccurrences,FileName)
End If
Next
End Sub
Solved! Go to Solution.
Link copied