I manage to make I-logic code, but its not working.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheets As Sheets
Dim oSheet As Inventor.Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
For Each oSheet In oDrawDoc.Sheets
oViews = oSheet.DrawingViews
For Each oView In oViews
If oView.ViewType <> 10504 Then ' Not kProjectedDrawingViewType
' Get the full filename of the view model
Dim oModelFileName As String
oModelFileName = oView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName
Dim oPartList As PartsList
' Try to get the parts list from the table of this sheet
Try
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
Catch ' On error, try and search all sheets for the first found parts list
' Iterate through each sheet
Dim i As Long
For i = 1 To oDrawDoc.Sheets.Count
If oDrawDoc.Sheets.Item(i).PartsLists.Count > 0 Then Exit For
Next
If oSheet.PartsLists.Count = 0 Then
MessageBox.Show("No Parts List found in the drawing.")
Exit Sub
End If
oPartList = oDrawDoc.Sheets.Item(i).PartsLists.Item(1)
End Try
' Iterate through the contents of the parts list.
Dim oRow As PartsListRow
Dim oRowFileName As String
Dim j As Long
For j = 1 To oPartList.PartsListRows.Count
' Get the current row
oRow = oPartList.PartsListRows.Item(j)
' Get filename of model in row
oRowFileName = oRow.ReferencedFiles.Item(1).FullFileName
' Compare the filenames
If StrComp(oModelFileName, oRowFileName, CompareMethod.Text) = 0 Then
' Get the value of Item from the Parts List (first item in the row)
Dim oItemValue As String
oItemValue = oRow.Item(1).Value
' Iterate through all the balloons in the sheet
Dim oBalloons As Balloons
Dim oBalloon As Balloon
oBalloons = oSheet.Balloons
For Each oBalloon In oBalloons
' Access the component that the balloon is attached to
Dim oBalloonComponent As ComponentOccurrence
oBalloonComponent = oBalloon.ReferencedComponent
' If the balloon is attached to the correct component, update the balloon text
If Not oBalloonComponent Is Nothing Then
If StrComp(oBalloonComponent.Definition.Document.FullFileName, oModelFileName, CompareMethod.Text) = 0 Then
' Set the balloon text to the item number (part number)
oBalloon.Text = oItemValue
End If
End If
Next
End If
Next
End If
Next
Next
MessageBox.Show("Balloon renumbering finished!")