Parts list sorting- grouping similar items

Parts list sorting- grouping similar items

Anonymous
Not applicable
1,213 Views
6 Replies
Message 1 of 7

Parts list sorting- grouping similar items

Anonymous
Not applicable

Hi, 

I wish to have my part list created in Inventor drawing to sorted on its own such that similar items are grouped together and in order.( I am able to sort items manually, but I am in search for code to do it for part lists with many items)

 

When we use part list option in Inventor, it sorts items in certain order, but I would like to know what program/coding is required to sorts those items in particular order. For example, in my assembly i have set of valves, flanges and fasteners, where I want all my valves to be listed at top of the part list, then all flanges together, then nuts and studs according to their size. I have attached a screenshot of how I like to have the part list. 

This will be helpful when i have a lot of items in the assembly.

I would appreciate if anyone can share the code/ program required to do this.

 

Sorting.JPG

0 Likes
1,214 Views
6 Replies
Replies (6)
Message 2 of 7

mcgyvr
Consultant
Consultant

You said "For Example".. Does your example cover ALL cases? Will their ONLY be the 5 different categories of parts in any/all parts lists you expect to sort?

Is the ONLY thing changing between all of your cases the addition of more Gate Valves/Flanges/Studs/Gaskets/Nuts.. Just more sizes of them?

Are the descriptions ALWAYS written as consistently as in your example?

Is the order ALWAYS.. All valves ascending in size, then all flanges ascending in size, then ring gaskets (just one size?) then you want pairs of stud/nuts grouped by size and this time Descending? 

 

While I appreciate organization.. Often times us Engineering types spend more time trying to organize then the effort is worth. Any reason just sorting by description isn't sufficient? That gets you most of the way..

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 7

Anonymous
Not applicable

Hi,

I wont be having the same categories of parts in my part list all the times, but my expectation is that mostly parts will be similar to these, so if I can get the code to sort the items I have mentioned in the example, it should suit most of my requirements.

Definitely I am not looking to edit the code for each and every part list, but once I get a code, I would edit by adding extra requirements like giving instructions to sort when I get other parts and in short " I will have one code to use for all my parts list of this type".

And I expect to do automatic sorting in  assemblies mostly having these parts like gate valves and flanges and always their descriptions will have the exact first and second word. A gate valve will always have first two words in description as gate valve, but then many additional descriptions like size, etc. will be there and hence sorting has to be based on the first and second words. If possible we have to sort by sizes among the categories, else we cant ignore sizes.

I wish to group studs/nuts in pairs according to size  and its not a problem if I cant sort to size but it should be at last of the order.

 

The reason why I am looking for a automatic sorting is, I have many similar set of assemblies so it will be good to automate it by code.

0 Likes
Message 4 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Try below Inventor API documentation link to reposition the row of parts list. Unfortunately, there is no direct sorting API as per mentioned way. Need to build your logic or code to parts list sorting.

 

http://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-24F77892-E1F6-4A39-BB21-943FE47FE76C

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 5 of 7

Anonymous
Not applicable

I think the code below will get you close to what you want (not perfect as it requires some prior setup).  I have commented out some lines that will require you to edit them to call out the correct iProperty fields and rename the columns to sort by.

 

The gist of the code is that you will have setup two additional iProperty fields, one for Component Priority (Valves, Flanges, etc) and then by increasing dimension size.  I am leaving the iProperty fields up to you but can help if needed.  My recommendation is that Valves are given a value of 1, Flanges a value of 2, so on and so forth.  Then in the other iProperty field given the dimensional value.

 

If this is done it should sort based on those fields and shrink the columns' width to zero, hiding the unnecessary columns/iProperty fields.

 

I will try to answer any questions you may have as quickly as possible.

 

Here is the code:

'Check that file is drawing document
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
	Return
End If

'Initialize to document
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView

'Check for View
If oSheet.DrawingViews.Count > 0 Then
	oView = oSheet.DrawingViews.Item(1)
Else
	MsgBox("There was no view on the Active Sheet to base the Parts List on. Exiting.", vbOKOnly + vbExclamation, "No View")
	Return
End If

'Check for Border
Dim oBorder As Border = oSheet.Border
Dim oPoint As Point2d
If oBorder IsNot Nothing Then
	' A border exists. The placement point
	' is the top-right corner of the border.
	oPoint = oBorder.RangeBox.MaxPoint
Else
	' There is no border. The placement point
	' is the top-right corner of the sheet.
	oPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)
End If

'Call Parts List Default
Dim oPListStyle As PartsListStyle = oDDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)")
Dim oPList As PartsList = oSheet.PartsLists.Add(oView, oPoint, PartsListLevelEnum.kStructured)
Dim oColumns As PartsListColumns = oPList.PartsListColumns
Dim oCol As PartsListColumn

'Title and Heading Setup
oPList.Style = oPListStyle
oPList.Title = "Parts List"
oPList.ShowTitle = True
oPList.HeadingPlacement() = kHeadingAtTop
oPList.TableDirection() = kTopDownDirection

'Add Columns
'Dim oSumSet As PropertySet = oDDoc.PropertySets.Item("Inventor Summary Information")
'Dim oPropSetID As String = oSumSet.InternalName
'Dim oTitle As [Property] = oSumSet.Item("Title")
'Dim oTitleId As Integer = oTitle.PropId

Dim oDTPropSet As PropertySet = oDDoc.PropertySets.Item("Design Tracking Properties")
Dim oDTPId As String = oDTPropSet.InternalName
'Dim oVendor As [Property] = oDTPropSet.Item("Vendor")
'Dim oVendorId As Integer = oVendor.PropId
Dim oDesc As [Property] = oDTPropSet.Item("Description")
Dim oDescId As Integer = oDesc.PropId

oColumns.Item(4).Remove
oColumns.Item(3).Remove
oColumns.Add(PropertyTypeEnum.kFileProperty, oDTPId, oDescId)
'oColumns.Add(PropertyTypeEnum.kFileProperty, oPropSetID, oTitleId)
'oColumns.Add(PropertyTypeEnum.kFileProperty, oDTPId, oVendorId)

'Format Column Names and Justification
oColumns.Item(1).Title = "ITEM"
oColumns.Item(2).Title = "QTY"
oColumns.Item(3).Title = "DESCRIPTION"
'oColumns.Item(3).Title = "Primary Column Title"
'oColumns.Item(4).Title = "Secondary Column Title"

PartsList.sort("Primary Column Title", True, "Secondary Column Title", True)

'Setting the Column Widths
For Each oCol In oColumns
	Select Case oCol.Title
	Case "ITEM"
		oCol.Width = .889
	Case "QTY"
		oCol.Width = .889
	Case "DESCRIPTION"
		oCol.Width = 3.683
'	Case "Primary Column Title"
'		oCol.Width = 0.0000
'	Case "Secondary Column Title"
'		oCol.Width = 0.0000
	End Select
Next

 

Message 6 of 7

robertast
Collaborator
Collaborator

For whom amendments to the parts list are important, let us not be lazy and vote for this idea.

https://forums.autodesk.com/t5/inventor-ideas/parts-list-bill-of-materials-for-sheet-rather-than-ass... 

 

Message 7 of 7

Anonymous
Not applicable

Thanks for working out to provide me this code.

I would like to get clarity on two things, I see here the partlist is sorted with the new custom I property column value, for that I should have access to edit the parts in the assembly, but I can't edit the individual parts, I have to take up the parts and create assembly with partlist.

If I manage to access the new custom I property value in the assembly, is it mandatory that this new column will be present in the partlist?  Is it possible to have partlist without these new fields shown.

Additional to this, is there a possibility to sort the partlist without doing adding a new custom i property, is it possible to sort just based on the first words of description: using an if statement to capture all the items with description of "Valves" to come first, next if loop to group "Flanges" next and then to sort the fasteners based on size. I am just enquiring whether it is possible?

 

0 Likes