Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

custom BOM column populated only when BOM structure is purchased

9 REPLIES 9
Reply
Message 1 of 10
BaronEngineering
268 Views, 9 Replies

custom BOM column populated only when BOM structure is purchased

I would like to have a custom column in the BOM editor that is automatically populated when the BOM structure of a part (or assembly) is set as purchased. I am trying to set up a format of columns to be exported to csv and then imported into an MRP system. The MRP system has to have a column that is blank for fabricated parts, but has some sort of indicator (x, $, etc.) for purchased parts. I feel this is possible using iLogic and "If, then" statements; however, I am not familiar with iLogic to be useful.

 

Thanks,

 

Nathan Presley

9 REPLIES 9
Message 2 of 10

Public Sub Main()

    ' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument 
    
    
    Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences, 1)

End Sub 

Private Sub TraverseAssembly(Occurrences As ComponentOccurrences, _ 
                             Level As Integer) 
    
    Dim oOcc As ComponentOccurrence 
    For Each oOcc In Occurrences 
    
    If oOcc.Definition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure
oOcc.Definition.Document.PropertySets.Item("Inventor User Defined Properties").Item("WO#").Value = "S"
End if ' Check to see if this occurrence represents a subassembly ' and recursively call this function to traverse through it. If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then Call TraverseAssembly(oOcc.SubOccurrences, Level + 1) End If Next End Sub

You can try this or something like this - untested so far.


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

I will try & see what happens. Thank you for the response.

Message 4 of 10

I created a column "WO#" in my test assembly per what I saw in the code. I then pushed that column to all the parts in the assembly to create a custom iproperty. When I run the rule, I get this message: "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))". I am quite novice and don't what to correct, check, or add. Thanks for help. I do appreciate the input.

 

-Nathan

Message 5 of 10

Did it change any of the files?


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

It added the custom iproperty to all the parts in the assembly. And "WO#" is selectable as a custom column with the BOM editor. However, the WO# isn't populated for anything.

Message 7 of 10

Does this help?

 

screen catch.jpg

Message 8 of 10

Sounds like its not to fond of the variable declarations.

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

I have no idea. This is over my head.
Message 10 of 10

Any thought on correction?

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

Post to forums  

Autodesk Design & Make Report