BOM clear manual sort with ilogic

BOM clear manual sort with ilogic

GeertvanderHeide
Advocate Advocate
789 Views
6 Replies
Message 1 of 7

BOM clear manual sort with ilogic

GeertvanderHeide
Advocate
Advocate

Hi, 

 

I want to control my BOM with ilogic for cutom user inputs. 

I already got the sort function and show function to work.

Only problem i got is that the ilogic code does not work when there is a manual sort on any collumn. 

Well the code works, but it does nothing. 

 

To clear this you have to click rmb on the collumn that is manually sorted, and then click clear sort. 

After this the code works fine.

 

Is there a way to built in a safety in ilogic that clears manual sorts?

 

Dim oAssem As AssemblyDocument = ThisDoc.Document

Dim oBOM As BOM = oAssem.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = True
Dim oBOMview As BOMView = oBOM.BOMViews.Item("structured")

'sort bom on base QTY Call oBOMview.Sort("Base QTY", False)
'show bom
Dim
oCM As CommandManager = ThisApplication.CommandManager Dim oCD As ControlDefinitions = oCM.ControlDefinitions Dim ShowBom As ControlDefinition = oCD.Item("AssemblyBillOfMaterialsCmd") ShowBom.Execute2(True)
'sort on item after bom closes Call oBOMview.Sort("Item", True) 'MsgBox("done") to check if the excecute2 fucntion is working.
0 Likes
Accepted solutions (1)
790 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

Have you tried clearing all manual sorts by placing nothing or “” in place of a sort if you have only 2 columns sorting? 


Syntax
BOMView.
Sort( PrimaryColumnTitle As String, [PrimaryColumnAscending] As Boolean, [SecondaryColumnTitle] As String, [SecondaryColumnAscending] As Boolean, [TertiaryColumnTitle] As String, [TertiaryColumnAscending] As Boolean )

 

Call oBOMview.Sort("Base QTY", False,”Item”,True,””,True)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

GeertvanderHeide
Advocate
Advocate

just tried it but that does not work.

then i get an error, because there is no property with an empty string. 

 

Call oBOMview.Sort("", False,)

the secondary en tertiary sorts are optional, so input is not required there. 

0 Likes
Message 4 of 7

A.Acheson
Mentor
Mentor

Hi The sort is removing all manual sort criteria in Inventor 2020.

Before Rule Running:

AAcheson_0-1655413630042.png

After Rule Running:

AAcheson_1-1655413769261.png

Dim oAssem As AssemblyDocument = ThisDoc.Document

Dim oBOM As BOM = oAssem.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = True
Dim oBOMview As BOMView = oBOM.BOMViews.Item("structured")

'Sort bom on Item
Call oBOMview.Sort("Item", True)

'show bom
Dim oCM As CommandManager = ThisApplication.CommandManager
 Dim oCD As ControlDefinitions = oCM.ControlDefinitions	
Dim ShowBom As ControlDefinition = oCD.Item("AssemblyBillOfMaterialsCmd")
ShowBom.Execute2(True)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 7

GeertvanderHeide
Advocate
Advocate

the problem is when you have the bom open. 

GeertvanderHeide_0-1655705997489.png

 when you click part number an arrow appears. 

when this arrow is shown in any collumn the code doesn's work.

this arrow can be removed by right clicking the collumn tab and select clear sort. 

but as far as i know there is no option to do this in code. 

0 Likes
Message 6 of 7

A.Acheson
Mentor
Mentor
Accepted solution

I see the missing functionality now. I have likely had this happen to me before and was unaware of the issue. I checked the API and the commands list and there seems to be no way to clear this Sort Ascending/Descending filter. What does work is to import a clean xml. Which may not be ideal if you have made changes. 

oBOM.ImportBOMCustomization("C:\Users\ImportBOMColumnSettings.xml")

Issue: No way to clear a manual Sort Ascending/Descending activated in the editor.

 

 

AAcheson_2-1655873110660.png

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 7

GeertvanderHeide
Advocate
Advocate

Ow that's a workaround does the job perfectly!

now i just exported the bom without any customization to an xml, and override that with the bom.

Only thing is that you override the bom everytime you run the rule. i don't know how much impact it has on performance, but what i can see now it works very smooth. 

 

Thanks!