Partslist custom sorting

Partslist custom sorting

machiel.veldkamp
Collaborator Collaborator
631 Views
4 Replies
Message 1 of 5

Partslist custom sorting

machiel.veldkamp
Collaborator
Collaborator

Hi!

 

I want to auto sort our partslists with iLogic and I made a beginning to find out what we want. 

 

I included a screenshot I can explain myself better. 

 

 

autoparts.PNG

 

We want to sort on 2 coloms simultanious kinda. 

 

We want to sort the numbers by the first number (format = No-ProjNo-001)

First sorting job is Partnumber

 

  • 94-projNo-x
  • 92-ProjNo-x
  • 4-ProjNo-x
  • 2-ProjNo-x
  • 1-ProjNo-x
  • 3-ProjNo-x
  • A
  • B
  • C
  • D

 

After that we want to sort by description

The 94 -> 92 -> 4 -> 2 -> - etc needs to be sorted but we want to group the descriptions. 

 

Example

 

1-part-009 = Sheet 2mm

1-part-007 = Sheet 2mm

1-part-269 = Sheet 5mm

1-part-100 = Sheet 6mm

 

So here the description is more inportant than the last 3 digits of the partnumber. 

 

 

Okay so. Here's my question

 

 

How can I sort these things  seperatly and then combine them again? 

 

I'd like to filter just the first digit of the partnumber and sort that and after that sort the small 'blocks' of 94's 2's 1's etc

 

 

Anyone that can point me in the right direction?

 

 

 

 

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes
632 Views
4 Replies
Replies (4)
Message 2 of 5

machiel.veldkamp
Collaborator
Collaborator

I made this for now but this sorts the whole partnumber and places tha alphabetical partsnumber above the numbered partnumbers. 

 

 

SyntaxEditor Code Snippet

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("PART NUMBER", 0, "DESCRIPTION", 0)

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes
Message 3 of 5

Ruffy85
Collaborator
Collaborator

@machiel.veldkamp

 

this is not possible trough the standard Sort function. 

 

The PartsList.sort function is the same, like what you can done manually in your PartsList on your Drawing.

 

There you can enter max. 3 Sort criterias. But what you want is customized search function. Thats not so easy.

 

In your case, only this should be possible ( numbers before characters acsending or descending)

 

1-ProjNo-x

2-ProjNo-x

3-ProjNo-x

4-ProjNo-x

92-ProjNo-x

94-projNo-x
A

B

C

D

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).
0 Likes
Message 4 of 5

machiel.veldkamp
Collaborator
Collaborator

Yeah I know. That's why I came asking 🙂

 

I found that the problem I have is called a Trie. 

 

 

https://stackoverflow.com/questions/40406132/group-numbers-by-shortest-prefix/40406656

Here is some more info on what it entails and how some people may fix it. 

 

Now just to port this to iLogic. 

 

 

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes
Message 5 of 5

MechMachineMan
Advisor
Advisor

 

Solution 1:

The "code friendly way" is to write an iComparable sort method to be called with a "List.Sort" in order to spit out at sorted list, then you need to use that outputted list to rearrange your browser nodes.

It's a lot of work.

 

 

Solution 2:

You could also just write your own comparison that runs on the parts list and sorts them based on a multi-tiered criteria sort. Again, a lot of work and a lot of understand of what goes on.

 

Solution 3:

You're probably better off assigning a "sort priority" iProperty in your BOM so it can cluster the things in a group.ie;

Part Number - Sort Priority value

Project number - 1

Sheet metals - 2

Misc material - 3

 

Then you sort your BOM by 'Sort priority' and then by Part Number' using the built in features, without API.

 

 

I highly recommend you work with solution 3.

 

Good luck.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes