BOM sorting and Renumbering in Assy

BOM sorting and Renumbering in Assy

Anonymous
Not applicable
969 Views
2 Replies
Message 1 of 3

BOM sorting and Renumbering in Assy

Anonymous
Not applicable

Hi

 

I have a custom itemnumber and qty ilogic code I use to get unique properties on each dwg.

The code runs from the main assy level in the 3D enviroment.

 

I would love to get the code to sort BOM by part number and then renumber items before doing what it already does.

 

I've seen it done very nicely from a drawing with iLogic, but I need it done directly from the 3D assy.

 

Any ideas?

0 Likes
970 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor

Look at this file:

 

"C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm"

 

Type in 'Application' in the search tab.

 

Select Application object. Understand that when you start a call with ThisApplication, this is the object that is returned.

 

Select a logical path to what you are looking for under the properties/methods of the Application Object (what is now viewable in the main screen).

ie ActiveDocument property.

 

(Our code would now read Dim oDoc As Document = ThisApplication.ActiveDocument)

 

Keep following through, and eventually you wind up at:

 

''''

Dim oDoc As Document

oDoc = ThisApplication.ActiveDocument

 

Dim oCompDef As ComponentDefinition

oCompDef= oDoc.ComponentDefinition

 

Try

Dim oBOM As BOM = oCompDef.BOM

oBOM = oCompDef.BOM

Catch

 

With oBOM

       .Sort() 'PLUS ARGUMENTS OF METHOD

       .Renumber 'PLUS ARGUMENTS OF METHOD

End With

''''

 


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

rhasell
Advisor
Advisor

Hi

 

I wrote some code to do exactly that.

 

I manged to get it to work 95% of the time, but it was unreliable. It would never sort the same way from one iteration to the next.

 

I found that making a GA drawing, and doing my sorts from a dummy GA drawing works 100% of the time.

 

Attached is a copy of my working code, it's old and have not looked at it for years, hopefully you can get something out of it.

 

 

 

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

' Set a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM

' Make sure that the parts only view is enabled.
    oBOM.PartsOnlyViewEnabled = True

' Set a reference to the "Parts Only" BOMView
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Parts Only")


Call oBOMView.Sort("BOM Structure",True ,"TYPE",True ,"Stock Number",True)
Call oBOMView.Renumber(1, 1)
MessageBox.Show("Done", "Sort BOM")

 

Reg
2026.1