<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error getting ComponentDefinition of BOMRow object within iAssembly (VBA) in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9255237#M104645</link>
    <description>&lt;P&gt;Unfortunately that is not how I have it setup. I think the critical thing here is there are multiple members which causes some sort of roll-up error. Here is what I have:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Created two assemblies &lt;STRONG&gt;each with a part in them&lt;/STRONG&gt; (SubSubAssembly1 &amp;amp; SubSubAssembly2)&lt;/LI&gt;&lt;LI&gt;Created an assembly and added the two subsub assemblies and then made it an iAssembly (T&lt;STRONG&gt;wo members&lt;/STRONG&gt;, where one member has SubSubAssembly1 active and SubSubAssembly2 excluded, the other member has the opposite), saved as SubAssembly1&lt;/LI&gt;&lt;LI&gt;Created an assembly and made it an iAssembly (&lt;STRONG&gt;Two members&lt;/STRONG&gt;), saved as Assembly1. Added SubAssembly1 where the first member of Assembly1 points to the first member of SubAssembly1 and the second member of Assembly1 points to the second member of SubAssembly1.&lt;/LI&gt;&lt;LI&gt;Ran the code, &lt;STRONG&gt;"yes"&lt;/STRONG&gt; to first-level only (Because Inventor won't show all-levels if you go to the Bill of Materials screen of Assembly1)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here are images showing my iAssembly tables:&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SubAssembly1 table" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/717680i42E4B4D8A09DD955/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="SubAssembly1 table" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;SubAssembly1 table&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Assembly1 table" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/717681i624AEB5AB752565D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="Assembly1 table" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Assembly1 table&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2020 16:15:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-01-16T16:15:36Z</dc:date>
    <item>
      <title>Error getting ComponentDefinition of BOMRow object within iAssembly (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9244314#M104468</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a unique scenario where when traversing the BOMRow of the structured BomView, the ComponentDefinition is "Nothing" (During this line in the code below: Set oCompDef = oRow.ComponentDefinitions.Item(1)).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/715678i3FCFB345A93CFFBD/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It only happens to items that are in iAssemblies that are two subassemblies deep. I've attached my file but here is the structured of my Assembly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Assembly1.iam&lt;OL&gt;&lt;LI&gt;SubAssembly1.iam&lt;OL&gt;&lt;LI&gt;SubSubAssembly1.iam&lt;/LI&gt;&lt;LI&gt;SubSubAssembly2.iam&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Assembly1.iam and SubAssembly1.iam are iAssemblies each with a different configurations of it's child assemblies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;The end goal is to export all the items from the highest level assembly, depending on which member is active (Assembly1.iam).&lt;/STRONG&gt; &lt;STRONG&gt;Why am I unable to get access to the ComponentDefinition? &lt;/STRONG&gt;&lt;/U&gt;It works in all other scenarios which makes me believe it has something to do with how Inventor combines the parts in the BOMView, specifially in iAssemblies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using, it's the same as ones I've seen floating around these forums. I am running Inventor 2018.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub BOMQuery()
    ' Set a reference to the assembly document.
    ' This assumes an assembly document is active.
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument

    Dim FirstLevelOnly As Boolean
    If MsgBox("First level only?", vbYesNo) = vbYes Then
        FirstLevelOnly = True
    Else
        FirstLevelOnly = False
    End If
    
    ' Set a reference to the BOM
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    
    ' Set whether first level only or all levels.
    If FirstLevelOnly Then
        oBOM.StructuredViewFirstLevelOnly = True
    Else
        oBOM.StructuredViewFirstLevelOnly = False
    End If
    
    ' Make sure that the structured view is enabled.
    oBOM.StructuredViewEnabled = True
    
    'Set a reference to the "Structured" BOMView
    Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Structured")
        
    Debug.Print "Item"; Tab(15); "Quantity"; Tab(30); "Part Number"; Tab(70); "Description"
    Debug.Print "----------------------------------------------------------------------------------"

    'Initialize the tab for ItemNumber
    Dim ItemTab As Long
    ItemTab = -3
    Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab)
End Sub

Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long)
    ItemTab = ItemTab + 3
    ' Iterate through the contents of the BOM Rows.
    Dim i As Long
    For i = 1 To oBOMRows.Count
        ' Get the current row.
        Dim oRow As BOMRow
        Set oRow = oBOMRows.Item(i)

        'Set a reference to the primary ComponentDefinition of the row
        Dim oCompDef As ComponentDefinition
        Set oCompDef = oRow.ComponentDefinitions.Item(1)

        Dim oPartNumProperty As Property
        Dim oDescripProperty As Property

        If Typeof oCompDef Is VirtualComponentDefinition Then
            'Get the file property that contains the "Part Number"
            'The file property is obtained from the virtual component definition
            Set oPartNumProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            'Get the file property that contains the "Description"
            Set oDescripProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Description")

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
        Else
            'Get the file property that contains the "Part Number"
            'The file property is obtained from the parent
            'document of the associated ComponentDefinition.
            Set oPartNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            'Get the file property that contains the "Description"
            Set oDescripProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Description")

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
            
            'Recursively iterate child rows if present.
            If Not oRow.ChildRows Is Nothing Then
                Call QueryBOMRowProperties(oRow.ChildRows, ItemTab)
            End If
        End If
    Next
    ItemTab = ItemTab - 3
End Sub&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jan 2020 23:16:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9244314#M104468</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-01-10T23:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error getting ComponentDefinition of BOMRow object within iAssembly (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9250797#M104551</link>
      <description>&lt;P&gt;I'm on 2017, so I couldn't use your attached files.&amp;nbsp; I attempted to recreate it with the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Created two empty assemblies (SubSubAssembly1 &amp;amp; SubSubAssembly2)&lt;/LI&gt;&lt;LI&gt;Created an assembly and added the two subsub assemblies and then made it an iAssembly (one member), saved as SubAssembly1&lt;/LI&gt;&lt;LI&gt;Created an assembly and placed SubAssembly1 (the only member), made it an iAssembly (one member), saved as Assembly1&lt;/LI&gt;&lt;LI&gt;Ran your code, "no" to first-level only&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Output was&lt;/P&gt;&lt;PRE&gt;Item          Quantity       Part Number                             Description
----------------------------------------------------------------------------------
1                1           SubAssembly1-01                         
  1.1            1           SubSubAssembly1                         
  1.2            1           SubSubAssembly2   &lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jan 2020 21:53:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9250797#M104551</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2020-01-14T21:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error getting ComponentDefinition of BOMRow object within iAssembly (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9255237#M104645</link>
      <description>&lt;P&gt;Unfortunately that is not how I have it setup. I think the critical thing here is there are multiple members which causes some sort of roll-up error. Here is what I have:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Created two assemblies &lt;STRONG&gt;each with a part in them&lt;/STRONG&gt; (SubSubAssembly1 &amp;amp; SubSubAssembly2)&lt;/LI&gt;&lt;LI&gt;Created an assembly and added the two subsub assemblies and then made it an iAssembly (T&lt;STRONG&gt;wo members&lt;/STRONG&gt;, where one member has SubSubAssembly1 active and SubSubAssembly2 excluded, the other member has the opposite), saved as SubAssembly1&lt;/LI&gt;&lt;LI&gt;Created an assembly and made it an iAssembly (&lt;STRONG&gt;Two members&lt;/STRONG&gt;), saved as Assembly1. Added SubAssembly1 where the first member of Assembly1 points to the first member of SubAssembly1 and the second member of Assembly1 points to the second member of SubAssembly1.&lt;/LI&gt;&lt;LI&gt;Ran the code, &lt;STRONG&gt;"yes"&lt;/STRONG&gt; to first-level only (Because Inventor won't show all-levels if you go to the Bill of Materials screen of Assembly1)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here are images showing my iAssembly tables:&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SubAssembly1 table" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/717680i42E4B4D8A09DD955/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="SubAssembly1 table" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;SubAssembly1 table&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Assembly1 table" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/717681i624AEB5AB752565D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="Assembly1 table" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Assembly1 table&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 16:15:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9255237#M104645</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-01-16T16:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error getting ComponentDefinition of BOMRow object within iAssembly (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9255401#M104647</link>
      <description>&lt;P&gt;Thanks for the additional details.&amp;nbsp; According to the documentation, the structured BOM in iAssemblies only supports first-level.&amp;nbsp; If I'm understanding what you're trying to do, you might want to use the model BOM.&amp;nbsp; Unfortunately, there's no item numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Set oBOMView = oBOM.BOMViews.Item("Unnamed")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 17:10:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9255401#M104647</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2020-01-16T17:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Error getting ComponentDefinition of BOMRow object within iAssembly (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9257850#M104710</link>
      <description>&lt;P&gt;Yes I was able to get that to export however I was hoping to do the structured view since it rolls up the quantities if the same part number is found in different subassemblies. How come the native export BOM button on the BOM screen allows an export of the structured view? It will grab everything I want it to, even two sub iAssemblies deep.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 17:13:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9257850#M104710</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-01-17T17:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error getting ComponentDefinition of BOMRow object within iAssembly (VBA)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9265163#M104813</link>
      <description>&lt;P&gt;The API has a number of limitations that native Inventor commands don't have.&amp;nbsp; Another odd one with BOM is there's no structured or parts-only views available through the API when the LOD is not set to master, however, they still show up with the native BOM command.&amp;nbsp; The best we can do is post suggestions and hope Autodesk listens.&amp;nbsp; In your case, a manual roll-up sounds like the simple work-around.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 18:33:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/error-getting-componentdefinition-of-bomrow-object-within/m-p/9265163#M104813</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2020-01-21T18:33:58Z</dc:date>
    </item>
  </channel>
</rss>

