Hello together,
how could I reorder the columns in the parts list for example No., Qty., Title?
Thank you very much
Georg
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Here is what I have put together for re-numbering. It will cycle through all of the sheets in the drawing file, sort, then re-number. Credit goes to the forum:
Dim oDoc As DrawingDocument = ThisDoc.Document Dim oSheet As Sheet For Each oSheet In oDoc.Sheets oSheet.Activate On Error Resume Next Dim oPartsList As PartsList oPartsList = oDoc.ActiveSheet.PartsLists.Item(1) oPartsList.Update() oPartsList.Sort("MATERIAL", 1, "DESCRIPTION", 1) '1 = Ascending
oPartsList.Renumber oPartsList.SaveItemOverridesToBOM Next
Hi Georg,
If I understand you correctly then this should be of help:
http://adndevblog.typepad.com/manufacturing/2014/10/reorder-parts-list-columns.html
Cheers,
For anyone looking to do something similar, here is a script that will re-order Parts List columns to the order specified. Specified columns that aren't in the parts list will be ignored. Columns in the parts list that aren't specified will end up at the end. Column names are not case-sensitive.
Sub Main() Dim oRuleTitle As String = "Reorder Parts List Columns" Dim oThisDoc As Inventor.DrawingDocument Try oThisDoc = ThisDoc.Document Catch MessageBox.Show("Activate a drawing first.",oRuleTitle,MessageBoxButtons.OK,MessageBoxIcon.Error) Return End Try Dim oSheet As Sheet = oThisDoc.ActiveSheet Dim oPartsList As PartsList = oSheet.PartsLists.Item(1) Dim oColumnList As New List(Of String) oColumnList.AddRange({"Item","Part Number","QTY","Description","Stock Number"}) Dim oTransaction As Inventor.Transaction = Nothing Dim i As Integer = 0 For Each oColumnName As String In oColumnList Dim oColumn As PartsListColumn = GetColumn(oPartsList,oColumnName) If oColumn IsNot Nothing Then i += 1 If i = oPartsList.PartsListColumns.Count Then Exit For Else If oPartsList.PartsListColumns.Item(i) Is oColumn Then Continue For Else If oTransaction Is Nothing Then oTransaction = ThisApplication.TransactionManager.StartTransaction(oThisDoc,"Reorder Parts List Columns") Call oColumn.Reposition(i, True) End If 'We're at the last column End If 'Column exists Next 'Column to re-order If oTransaction IsNot Nothing Then oTransaction.End End Sub Function GetColumn(oPartsList,oColumnName) As PartsListColumn For Each oColumn As PartsListColumn In oPartsList.PartsListColumns If oColumn.Title.ToUpper = oColumnName.ToUpper Then Return oColumn Next 'Column in Parts List Return Nothing End Function