Firstly I suggest you to post to Inventor Customization forum for Inventor API & iLogic questions. Below is the updated iLogic code to show the progress bar, hope it helps:
Sub Main()
Call UpdateWeightOfiParts
End Sub
Sub UpdateWeightOfiParts()
' Get the active document. This assumes it is a part.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
' Check that this part is an iPart factory.
If Not oPartDoc.ComponentDefinition.IsiPartFactory Then
MsgBox ("This part must be an iPart factory.")
Exit Sub
End If
Dim oFactory As iPartFactory
oFactory = oPartDoc.ComponentDefinition.iPartFactory
' Check that there's a "Weight" column in the iPart table,
' and get its index in the table.
Dim iWeightColumnIndex As Long
iWeightColumnIndex = GetColumnIndex(oFactory, "Weight")
If iWeightColumnIndex = -1 Then
MsgBox ("The column ""weight"" does not exist in the table.")
Exit Sub
End If
Dim oProgressBar As Inventor.ProgressBar
oProgressBar = ThisApplication.CreateProgressBar(False,oFactory.TableRows.Count,"iPart Table Mass Update Process")
' Iterate through the rows
Dim oRow As iPartTableRow
For Each oRow In oFactory.TableRows
' Make this the active row so the model will recompute.
oFactory.DefaultRow = oRow
' Get the weight.
Dim dWeight As Double
dWeight = oPartDoc.ComponentDefinition.MassProperties.Mass
' Convert it to current mass units defined by the document.
Dim strWeight As String
strWeight = oPartDoc.UnitsOfMeasure.GetStringFromValue(dWeight, kDefaultDisplayMassUnits)
' Set the row value for the weight column.
oRow.Item(iWeightColumnIndex).Value = strWeight
oProgressBar.UpdateProgress
Next
oProgressBar.Close
End Sub
'' Function that given a factory and the name or a column will return
'' the index number of the column, if it's found in the factory's
'' table. If the column is not found it returns -1. The comparison
'' of the name is done in a case insensitive way.
Private Function GetColumnIndex(ByVal Factory As iPartFactory,ByVal ColumnName As String) As Long
' ' Iterate through all of the columns looking for a
' ' match to the input name.
Dim i As Long
For i =1 To Factory.TableColumns.Count
Dim oColumn As iPartTableColumn
oColumn = Factory.TableColumns.Item(i)
' ' Compare this column with the input name.
If LCase(oColumn.DisplayHeading)= LCase(ColumnName) Then
' A matching column was found so exit.
GetColumnIndex = i
Exit Function
End If
Next
' The column wasn't found so return -1.
GetColumnIndex = -1
End Function
If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.
Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.