In my test assembly drawing, I am using the following settings in my TextStyle:
(all numbers in these settings are in Inches)

And I am using the following PartsListStyle settings:

Then I manually adjusted all column widths to way wider than they needed to be, just for the test.
And here is the updated iLogic rule (based on @Lesoux c# code, kudos):
'Public Sub FitColumnsWidth(oPartsList As PartsList)
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
For Each oSheet As Inventor.Sheet In oDDoc.Sheets
For Each oPList As PartsList In oSheet.PartsLists
Dim oPPoint As Point2d = oTG.CreatePoint2d(0,0)
Dim oTempGNote As Inventor.GeneralNote = oSheet.DrawingNotes.GeneralNotes.AddFitted(oPPoint, "", oPList.DataTextStyle)
Dim oColQty As Integer = oPList.PartsListColumns.Count
Dim oWidths(oColQty) As Double
Dim i As Integer
For i = 0 To oColQty - 1
Dim oNext As Integer = i + 1
oTempGNote.Text = oPList.PartsListColumns(oNext).Title
oWidths(i) = oTempGNote.FittedTextWidth
For Each oRow As PartsListRow In oPList.PartsListRows
If oRow.Visible Then
oTempGNote.Text = oRow(oNext).Value
If oTempGNote.FittedTextWidth > oWidths(i) Then
oWidths(i) = oTempGNote.FittedTextWidth
End If
End If
Next
oPList.PartsListColumns(oNext).Width = oWidths(i) + (oPList.DataTextStyle.FontSize * .5)
Next
oTempGNote.Delete()
Next
Next
End Sub
When I ran this rule, it seemed to work exactly as I wanted it to. It narrowed all of the PartsList columns, seemingly the maximum amount, without causing them to squish too narrow, and without causing the contents of any of the cells to wrap to new lines/rows. Even after zooming in as far as possible on the end of the column divider, and attempting to manually adjust that divider to narrow the column, it wouldn't go ANY narrower.
Then I tested manually narrowing one of my columns, so that some of the cell contents within wrapped to new rows, then ran the rule. It corrected the column width, so that the contents of that row no longer wrap to a new row, just as I was hoping for.
Now, this may not be an ideal solution for the situations where you need your content to wrap to new rows, in order to fit the PartsList within a certain available width, or need to maintain a maximum width. In that situation, you may need to either add some additional code which sets your limitations, then checks and adjusts the outcome accordingly, or you may need to use a different technique.
Wesley Crihfield

(Not an Autodesk Employee)