Sort part list by part number

Sort part list by part number

firelinsgs
Enthusiast Enthusiast
577 Views
5 Replies
Message 1 of 6

Sort part list by part number

firelinsgs
Enthusiast
Enthusiast

Hi, i trying to Sort part list by Part number. But this code doesnt work for me. Only renumbering works..

 

Any idea why?

 

SyntaxEditor Code Snippet

On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
If Not oPartsList Is Nothing Then 
Call oPartsList.Sort("PART NUMBER")
oPartsList.Renumber
oPartsList.SaveItemOverridesToBOM
End If

 

0 Likes
Accepted solutions (1)
578 Views
5 Replies
Replies (5)
Message 2 of 6

rhasell
Advisor
Advisor

Works just fine, the sort just isn't that good, You may find that you get random results between drawings. It's still sorted, just not what you expect.

 

I find that you may need to add additional items to the parts list to improve the sorting. You can sort up to 3 columns.

 

TIP:

When you create the Parts list, change the column width to '1' this will effectively hide the column from view.

 

EG:

 

oPartsList.Sort("COST CENTER",1,"TYPE", 1, "STOCK NUMBER", 1)

 

"Cost Center" as Broad strokes sorting

"Type" is a custom field for finer sorting.

etc

 

In this example all the columns beyond "Length" are hidden from view.

 

partslist sort.PNG

 

 

 

Reg
2026.1
0 Likes
Message 3 of 6

firelinsgs
Enthusiast
Enthusiast

Thanks for your reply. But what i want is just simple short the part list by "Part Number" and renumber item.

Check attachment files.

 

I use INV. 2018 

 

test.PNG

0 Likes
Message 4 of 6

rhasell
Advisor
Advisor
Accepted solution

Hi

 

The Sample data was perfect.

Found the problem.

 

The "PART NUMBER" is case sensitive, The code and the Parts list don't match.

 

Revised code:

 

On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList As PartsList
oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
If Not oPartsList Is Nothing Then 
Call oPartsList.Sort("Part number",1)
oPartsList.Renumber
oPartsList.SaveItemOverridesToBOM
End If

 

Reg
2026.1
Message 5 of 6

firelinsgs
Enthusiast
Enthusiast

Thanks, 🙂 So little difference and it does work.

0 Likes
Message 6 of 6

rhasell
Advisor
Advisor

Pleasure

 

Glad I could help.

Reg
2026.1
0 Likes