Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

reorder columns in parts list

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
GeorgK
468 Views, 4 Replies

reorder columns in parts list

Hello together,

 

how could I reorder the columns in the parts list for example No., Qty., Title?

 

Thank you very much

 

Georg

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: GeorgK

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
Message 3 of 5
adam.nagy
in reply to: GeorgK

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, 



Adam Nagy
Autodesk Platform Services
Message 4 of 5
GeorgK
in reply to: adam.nagy

Hello Adam,

thank you very much.

Georg
Message 5 of 5
DRoam
in reply to: GeorgK

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report