Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BOM clear manual sort with ilogic

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
GeertvanderHeide
559 Views, 6 Replies

BOM clear manual sort with ilogic

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.
Tags (2)
Labels (2)
6 REPLIES 6
Message 2 of 7

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
Message 3 of 7

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. 

Message 4 of 7

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
Message 5 of 7

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. 

Message 6 of 7

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
Message 7 of 7

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!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report