Change BOM structure of all assy children to Phantom

Change BOM structure of all assy children to Phantom

brendan.henderson
Advisor Advisor
1,878 Views
4 Replies
Message 1 of 5

Change BOM structure of all assy children to Phantom

brendan.henderson
Advisor
Advisor

Hi all.

 

I am aware of iLogic but do not have the time to learn it (and am to old to remeber it anyway). Hoping someone can help me with what I think should be easy to code.

 

I have been supplied a STEP file that when imported into Inventor creates many sub-assy's and parts. All good as I need to delete some. What I need to acheive is to change the BOM structure of all sub-assy's and all their parts to Phantom. I can easily change the top level assy to Phantom.

 

Making the top level assy Reference is not an option because this does strange stuff in IDW's. If all files become Phantom they are excluded from a drawing Parts List nd they display just fine in the IDW.

 

Any takers?

Brendan Henderson
CAD Manager


New Blog | Old Blog | Google+ | Twitter


Inventor 2016 PDSU Build 236, Release 2016.2.2, Vault Professional 2016 Update 1, Win 7 64 bit


Please use "Accept as Solution" & give "Kudos" if this response helped you.

0 Likes
Accepted solutions (1)
1,879 Views
4 Replies
Replies (4)
Message 2 of 5

MechMachineMan
Advisor
Advisor
Accepted solution

This should accomplish what you asked for. It will even make library/cc parts phantom too, so be warned.

 

SyntaxEditor Code Snippet

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 
    Try
    oOcc.Definition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure
    Catch
    'MsgBox(oOcc.Name & "remains unchanged")
    End Try
        ' 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


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

brendan.henderson
Advisor
Advisor

That did the job. Many thanks too you.

Brendan Henderson
CAD Manager


New Blog | Old Blog | Google+ | Twitter


Inventor 2016 PDSU Build 236, Release 2016.2.2, Vault Professional 2016 Update 1, Win 7 64 bit


Please use "Accept as Solution" & give "Kudos" if this response helped you.

0 Likes
Message 4 of 5

brendan.henderson
Advisor
Advisor

I don't know why but now this previously working macro fails. See the picture. Anybody know how to fix this? I'm still on 2014 if that matters.

 

error.jpg

Brendan Henderson
CAD Manager


New Blog | Old Blog | Google+ | Twitter


Inventor 2016 PDSU Build 236, Release 2016.2.2, Vault Professional 2016 Update 1, Win 7 64 bit


Please use "Accept as Solution" & give "Kudos" if this response helped you.

0 Likes
Message 5 of 5

MechMachineMan
Advisor
Advisor

Hi. It's failing because the code is written in VB.net, whereas the macro feature in inventor only works for VBA. However, the vb.net is still fine for use in rules and external rules.

Adding a "Set" in front of variable declarations converts most of it over.

ie; Set oAsmDoc = ThisApplication.ActiveDocument


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