Drawing Parts Lists Row Sorting

Drawing Parts Lists Row Sorting

Jason.Rugg
Collaborator Collaborator
415 Views
4 Replies
Message 1 of 5

Drawing Parts Lists Row Sorting

Jason.Rugg
Collaborator
Collaborator

The attached pic is an example parts list and how we like them structured. Looking for a way to automate the sorting process of all parts lists on a drawing. Our parts lists contain 3 specific groups organized in the following order, MK #'s, Purchased items, and hardware.

 

Lines with MK #'s all contain an MK # at the end of the description such as MK A-84480001 and are sorted by drawing number first (84480001) and then the MK #. 

DESCRIPTION, MK A-84480001

DESCRIPTION, MK B-84480001

DESCRIPTION, MK A-84480002

DESCRIPTION, MK B-84480002

 

Lines with Purchased items don't really need to be sorted in any fashion other than raw material type items such as tube, pipe, steel... and would be nice if those items could be grouped together and sorted from shortest length to longest.

 

Lines with hardware contain nuts, bolts, washers... and would like those grouped and sorted from smallest to largest. Currently we aren't really sorting these lines other than them being the last portion of the parts list.

 

 Anything that can help us get closer to this formatting would be very useful, not sure if this is possible or not.

 

2021-11-24 10_39_29-Autodesk Inventor Professional 2019.png

0 Likes
416 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @Jason.Rugg.  I don't know if you are familiar with the two built-in methods defined under the PartsList object for sorting them or not, but here are the two links to them, just for reference (Sort, Sort2).  I doubt what you are asking could be done by either of them alone.  To do all of what you are asking would likely require a lot of code, some trial and error testing on some test files, and possibly some 'inside' knowledge about what these rows represent.  We can't see the column headers in the image you posted either.  Are all nuts, bolds, & washer type rows going to be representing Content Center items?  Is the BOMStructure of each component set to Purchased for the purchased items?  How would we distinguish, within the code, which rows represent raw materials, such as tube, pipe, steel etc. from other items?  It looks like we would have to attempt to 'isolate' the MK# and/or drawing # out of a larger description type text/String.  When it is found, will it always be the same number of characters in length, and always have the same spacing, etc?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

JelteDeJong
Mentor
Mentor

I think that this example will sort the MK lines but will the rest as is. If you need help expanding the rule additional information is needed (as WCrihfield already mentioned)

 

Sub Main()
    Dim doc As DrawingDocument = ThisDoc.Document
    Dim sheet As Sheet = doc.ActiveSheet
    Dim pl As PartsList = sheet.PartsLists.Item(1)

    Dim descriptionColumnNumber = GetColumnNumber(pl, "DESCRIPTION")

    Dim list As List(Of PartsListRow) = pl.PartsListRows.
        Cast(Of PartsListRow).
        Where(Function(row) row.Item(descriptionColumnNumber).Value.Contains(", MK ")).
        OrderBy(Function(row) row.Item(descriptionColumnNumber).Value).ToList()

    For i = 0 To list.Count - 1
        list.Item(i).Reposition(i)
    Next

End Sub
Private Function GetColumnNumber(partsList As PartsList, name As String) As Integer
    Dim columnNumber = -1
    For i = 1 To partsList.PartsListColumns.Count
        Dim column As PartsListColumn = partsList.PartsListColumns.Item(i)
        If (column.Title.Equals(name)) Then
            columnNumber = i
        End If
    Next
    Return columnNumber
End Function

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 4 of 5

Jason.Rugg
Collaborator
Collaborator

@JelteDeJong @WCrihfield This is a good start, it's atleast grouping the MK#'s at the top (not the right order) but its gathering them. After the holiday break I will provide some more info about our parts list and we can go from there. 

0 Likes
Message 5 of 5

rhasell
Advisor
Advisor

Hi

Combined with iLogic the following might work for you as well.

 

You can add additional sort columns, you can sort up to 3 columns.

I use this to separate various categories, as you are looking to do, I will force items to the bottom of the Parts list by adding a 'z' or an 'x' - prefix.

 

This does take some time to setup, as none of your parts/assemblies have the iProperties populated yet.

The Parts list needs to have these columns as well. These can be hidden from view by setting the column with to '1'

The easiest it to change the drawing template, parts list standard, to always hide the additional columns.

 

Just a thought, it might work for you.

 

Example of sort.

 

partslist.pngpartlist 2.png

Reg
2026.1