find occurrence in assembly based on BOM View item

find occurrence in assembly based on BOM View item

NachoShaw
Advisor Advisor
601 Views
2 Replies
Message 1 of 3

find occurrence in assembly based on BOM View item

NachoShaw
Advisor
Advisor

Hi,

 

Not entirely sure if this is possible... I am using the code from the API to loop through my BOM of the active assembly. This returns the BOM values on ALL occurence regardless whether they are visible / invisible & suppressed / enabled.

 

In the code, it uses this code for a componentDefinition

Dim i As Long
        For i = 1 To oBOMRows.Count
            ' Get the current row.
            Dim oRow As Inventor.BOMRow = oBOMRows.Item(i)

            'Set a reference to the primary ComponentDefinition of the row
            Dim oCompDef As Inventor.ComponentDefinition = oRow.ComponentDefinitions.Item(1)

 oCompDef is the component Definition of of the occurrence in the assembly. How can i check to see if this occurrence is visible in the assembly?

 

Thanks

 

Nigel

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


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

NachoShaw
Advisor
Advisor

No one? 😞

 

there must be a way to link a component definition to a component

 

 

Cheers

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 3 of 3

NachoShaw
Advisor
Advisor

Ok to bump this for a little help 🙂

 

I can find an occurrence in the assembly by getting the FullFileName of component definition from the BOM row and passing it to the documents.ItemByName but it takes too long because i need to iterate through the Assembly each time to find the occurrence. For example,

 

My Assembly has 150 unique components so, my BOM has 150 rows.

to find each occurrence by iterating through the assembly, i have in total, 150 x 150 iterations (22500) on the basis that each iteration in 150 rows has 150 iterations to find the occurrence.

 

THERE MUST BE AN EASIER WAY 🙂

 

Obviously, the BOM is linked to an assembly and each row in the BOM is linked to a component occurrence. How can i find that particular occurrence in the assembly to check its visibility? I am using Part Only structure.

 

Here is my current method-

Dim oCompDef As Inventor.ComponentDefinition = oRow.ComponentDefinitions.Item(1)

Dim oAsmDoc As Inventor.AssemblyDocument = _invApp.ActiveDocument

 Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition

Dim sDocName As String
            sDocName = oCompDef.Document.FullFileName

Dim oDoc As Inventor.Document
            oDoc = _invApp.Documents.ItemByName(sDocName)

' '' Get the occurrences that represent this document.
            Dim oOccs As ComponentOccurrencesEnumerator
            oOccs = oAsmCompDef.Occurrences.AllReferencedOccurrences(oDoc)


            '' Iterate through the Occurrences
            Dim oOcc As Inventor.ComponentOccurrence
            For Each oOcc In oOccs
                If oOcc.Visible = True Then
                Dim sName As String = oOcc.Name
                'Add name to excel sheet
            Next




 Can someone help me just a little please?

 

 

 

Thanks

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes