<?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: VBA script: List first level sub components from assembly in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3546426#M135584</link>
    <description>&lt;P&gt;Sorry for bumping this but I'm still trying to figure this one out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also perhaps something to clarify what I mean. Lets say I have the main assembly Thing.iam, I'd like to be able to get part1, assembly1, and part4. Not anything beyond the parts/assemblies in Thing.iam.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thing.iam&lt;/P&gt;&lt;P&gt;-Part1.ipt&lt;/P&gt;&lt;P&gt;-Assembly1.iam&lt;/P&gt;&lt;P&gt;--Part2.ipt&lt;/P&gt;&lt;P&gt;--Part3.ipt&lt;/P&gt;&lt;P&gt;-Part4.ipt&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2012 15:04:26 GMT</pubDate>
    <dc:creator>pball</dc:creator>
    <dc:date>2012-07-20T15:04:26Z</dc:date>
    <item>
      <title>VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3529766#M135583</link>
      <description>&lt;P&gt;Currently I have some code which loops through all sub components of an assembly and sub assemblies. However I only need sub components inside the top level assembly and not any sub-assemblies. Is there an easy way to acomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code will list all sub components inside an assembly when a drawing is open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Dim oDocument As Document
    Set oDocument = ThisApplication.ActiveDocument
    Dim oRefDocs As DocumentsEnumerator
    Set oRefDocs = oDocument.AllReferencedDocuments
    Dim oRefDoc As Document

    For Each oRefDoc In oRefDocs
        debug.print oRefDoc.FullDocumentName
    Next&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2012 19:48:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3529766#M135583</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2012-07-06T19:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3546426#M135584</link>
      <description>&lt;P&gt;Sorry for bumping this but I'm still trying to figure this one out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also perhaps something to clarify what I mean. Lets say I have the main assembly Thing.iam, I'd like to be able to get part1, assembly1, and part4. Not anything beyond the parts/assemblies in Thing.iam.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thing.iam&lt;/P&gt;&lt;P&gt;-Part1.ipt&lt;/P&gt;&lt;P&gt;-Assembly1.iam&lt;/P&gt;&lt;P&gt;--Part2.ipt&lt;/P&gt;&lt;P&gt;--Part3.ipt&lt;/P&gt;&lt;P&gt;-Part4.ipt&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2012 15:04:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3546426#M135584</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2012-07-20T15:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3546862#M135585</link>
      <description>&lt;P&gt;what do you want first level? the name or part itself?some information are in the first level BOM or partslist.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2012 19:30:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3546862#M135585</guid>
      <dc:creator>skyngu</dc:creator>
      <dc:date>2012-07-20T19:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3546866#M135586</link>
      <description>&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Set oRefDocs = oDocument.ReferencedDocuments&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2012 19:31:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3546866#M135586</guid>
      <dc:creator>skyngu</dc:creator>
      <dc:date>2012-07-20T19:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3561936#M135587</link>
      <description>&lt;P&gt;Set oRefDocs = oDocument.ReferencedDocuments&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That only returns the assembly included in the drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like the FullDocumentName for all the parts and sub-assemblies contained within the assembly placed in a drawing, but not any parts or assemblies deeper than that first level.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2012 20:23:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3561936#M135587</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2012-08-01T20:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3562030#M135588</link>
      <description>&lt;P&gt;The below is in VB.NET but you should be able to see how it was done and add make it work in VBA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
            ListBox1.Items.Clear()
            Dim oDrawing As DrawingDocument = ThisApplication.ActiveDocument
            'we will go after the first view that is an assembly
            For Each oView As DrawingView In oDrawing.ActiveSheet.DrawingViews
                If oView.ReferencedDocumentDescriptor.ReferencedDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                    Dim oAssembly As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
                    For Each oDoc As Inventor.Document In oAssembly.ReferencedDocuments
                        ListBox1.Items.Add(oDoc.FullDocumentName)
                    Next
                    Exit For ' we only want to do this for the first assembly found.
                End If
            Next
        End If&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2012 21:04:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3562030#M135588</guid>
      <dc:creator>Mike.Wohletz</dc:creator>
      <dc:date>2012-08-01T21:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3562380#M135589</link>
      <description>&lt;P&gt;well, oDocument means "assembly document" in the drawing&amp;nbsp;in this case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume that there is only one assembly in the drawing. after you can get assembly from drawing, you can get first level by referenceddocuments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you may get fulldocumentname from firstlevelonly bom or partslist too.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 05:36:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3562380#M135589</guid>
      <dc:creator>skyngu</dc:creator>
      <dc:date>2012-08-02T05:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: VBA script: List first level sub components from assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3566704#M135590</link>
      <description>&lt;P&gt;Thank you, it took a bit of playing around but I got exactly what I wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Dim oDocument As Document
    Set oDocument = ThisApplication.ActiveDocument
    Dim oRefDoc As Inventor.Document
    
    If oDocument.ReferencedDocuments.Item(1).DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        Dim oAssembly As AssemblyDocument
        Set oAssembly = oDocument.ReferencedDocuments.Item(1)
        
        For Each oRefDoc In oAssembly.ReferencedDocuments
            'add to list here oRefDoc.FullDocumentName
        Next
    ElseIf oDocument.ReferencedDocuments.Item(1).DocumentType = DocumentTypeEnum.kPartDocumentObject Then
        Set oRefDoc = oDocument.ReferencedDocuments.Item(1)
        
        'add to list here oRefDoc.FullDocumentName
    End If&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works nicely for me for getting either the part name or all first level components of an assembly. I needed this for a dialog which allows editing of iproperties from inside of a drawing, which saves loads of time.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2012 14:26:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-script-list-first-level-sub-components-from-assembly/m-p/3566704#M135590</guid>
      <dc:creator>pball</dc:creator>
      <dc:date>2012-08-06T14:26:32Z</dc:date>
    </item>
  </channel>
</rss>

