Accessing the BOM Structure column through VBA.

Accessing the BOM Structure column through VBA.

shastu
Advisor Advisor
2,082 Views
3 Replies
Message 1 of 4

Accessing the BOM Structure column through VBA.

shastu
Advisor
Advisor

When you open the BOM in the dialog box is a column called BOM Structure.  See attachment.  How can I access that column in VBA?  For example, If I want to skip some code based off of when that value is "Reference" how can I do that?

0 Likes
2,083 Views
3 Replies
Replies (3)
Message 2 of 4

shastu
Advisor
Advisor

Here is a simple example:

 

Public Sub ShowReferences()
    ' Get the active assembly.
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument

    ' Get all of the referenced documents.
    Dim oRefDocs As DocumentsEnumerator
    Set oRefDocs = oAsmDoc.AllReferencedDocuments

    ' Iterate through the list of documents.
    Dim oRefDoc As Document
    For Each oRefDoc In oRefDocs
        'If BOM Structure = Reference Then GoTo Skip:
        Debug.Print oRefDoc.DisplayName
       
    Next
Skip:

End Sub

 

I need the code to make the last commented line work.  "If BOM Structure = Reference, Then it would go to Skip.

0 Likes
Message 3 of 4

MechMachineMan
Advisor
Advisor

You need to be careful about how you fetch the BOM Structure.

 

The occurrence stores a BOM Structure override value which MAY be different than the BOM Structure stored in the Document file.

 

The BOM shown in the assembly lists the parts with the BOM structures according to the occurrence BOM structure overrides.

 

This means that doing a "for all ref'd docs fetch document BOM structure" may provide inaccurate results.

 

(The occurrence BOM Structure override is set by right clicking the occurrence leaf node in the assembly. it only ever gives 2 options; Default, or Reference)

 

Read my replies in this thread for quick how to on using the object browser/API. Which is what you should be learning if you are getting this far into vba already.

http://forums.autodesk.com/t5/inventor-customization/add-selection-filter-to-ilogic-code/m-p/6700118...


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

shastu
Advisor
Advisor

Yes, I know.  I tried using oRefDoc.ComponentDefinition.BOMStructure = 51972 but it does not recognize it as 51972 unless I physically open the BOM and change it from there.  If I just change the occurrence BOM Structure override by right clicking the occurrence leaf node in the assembly, it does not change it to 51972 but that is how we are doing it.  How can I determine if that is still on the Default or been changed to Reference?  I looked at your link, but am confused.

0 Likes