<?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: Get all occurrences (ipts, iams) from all levels in top assembly in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12643424#M12382</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5053305"&gt;@ReneRepina&lt;/a&gt;.&amp;nbsp; Just one small additional tip...&amp;nbsp; I am not sure what you are planning on doing with all of those components once you have access to them, but there is one other detail about 'how' you get them that might be important to the process.&amp;nbsp; Once you have access to a true top level component (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ComponentOccurrence" target="_blank" rel="noopener"&gt;ComponentOccurrence&lt;/A&gt;), how you access its child components can sometimes be important, depending on your plans.&amp;nbsp; If you use something like the following:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;ComponentOccurrence.Definition.Occurrences&lt;/LI-CODE&gt;
&lt;P&gt;...then you are getting them from within its &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ComponentDefinition" target="_blank" rel="noopener"&gt;ComponentDefinition&lt;/A&gt;, which is like opening the assembly document that it references, then accessing its top level components, so they are all in the 'context' of that component's referenced AssemblyComponentDefinition.&amp;nbsp; However, when you use the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ComponentOccurrence_SubOccurrences" target="_blank" rel="noopener"&gt;ComponentOccurrence.SubOccurrences&lt;/A&gt;&amp;nbsp;to access them, they are all still essentially in the same 'context' as the component itself (top level of the assembly).&amp;nbsp; By context I mean the 3D coordinate system space of a specific ComponentDefinition.&amp;nbsp; If you are working with measurements, constraints, or any other inter component geometry relationships, then context is very important because both objects need to be in the same context for these types of actions to work.&amp;nbsp; Also, iterating components (instead of iterating referenced documents) is the only way to control inter component context needed for those types of tasks.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2024 15:24:26 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-03-15T15:24:26Z</dc:date>
    <item>
      <title>Get all occurrences (ipts, iams) from all levels in top assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12642971#M12379</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any available code to get all occurrences (ipts, iams) from all levels in top assembly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Property "AllLeafOccurrences" exist, but it gets only all parts (ipts), without assemblies (iams).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Rene Repina&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 12:15:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12642971#M12379</guid>
      <dc:creator>ReneRepina</dc:creator>
      <dc:date>2024-03-15T12:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: Get all occurrences (ipts, iams) from all levels in top assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12643066#M12380</link>
      <description>&lt;P&gt;&lt;A href="https://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html" target="_blank" rel="noopener"&gt;See the first rule in this article traverse assembly.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It is written in VBA so it's needs to be converted. Remove the word "Set", add sub Main to drive the sub routine and change debug.print to logger.info.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have any issues converting then post the problem area with the error messages.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 12:53:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12643066#M12380</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2024-03-15T12:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Get all occurrences (ipts, iams) from all levels in top assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12643099#M12381</link>
      <description>&lt;P&gt;Yes, a recursive loop.&lt;/P&gt;&lt;P&gt;VBA, this is used to set all parts in assembly to same Material.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Private Sub SetAllMat(ByVal oSubDoc As Inventor.Document, oMatName As String)
    
    Dim oCompDoc As Inventor.PartDocument
    Dim oRefDoc As Inventor.Document
    For Each oRefDoc In oSubDoc.ReferencedDocuments
      If oRefDoc.ReferencedDocuments.Count &amp;gt; 0 Then
        Call SetAllMat(oRefDoc, oMatName)
      End If
      If oRefDoc.IsModifiable Then
        If oRefDoc.DocumentType = kPartDocumentObject Then
          Set oCompDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName)
          SetPartMaterial oCompDoc, oMatName
          oCompDoc.Close
        End If
      End If
    Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 13:12:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12643099#M12381</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2024-03-15T13:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get all occurrences (ipts, iams) from all levels in top assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12643424#M12382</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5053305"&gt;@ReneRepina&lt;/a&gt;.&amp;nbsp; Just one small additional tip...&amp;nbsp; I am not sure what you are planning on doing with all of those components once you have access to them, but there is one other detail about 'how' you get them that might be important to the process.&amp;nbsp; Once you have access to a true top level component (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ComponentOccurrence" target="_blank" rel="noopener"&gt;ComponentOccurrence&lt;/A&gt;), how you access its child components can sometimes be important, depending on your plans.&amp;nbsp; If you use something like the following:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;ComponentOccurrence.Definition.Occurrences&lt;/LI-CODE&gt;
&lt;P&gt;...then you are getting them from within its &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ComponentDefinition" target="_blank" rel="noopener"&gt;ComponentDefinition&lt;/A&gt;, which is like opening the assembly document that it references, then accessing its top level components, so they are all in the 'context' of that component's referenced AssemblyComponentDefinition.&amp;nbsp; However, when you use the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ComponentOccurrence_SubOccurrences" target="_blank" rel="noopener"&gt;ComponentOccurrence.SubOccurrences&lt;/A&gt;&amp;nbsp;to access them, they are all still essentially in the same 'context' as the component itself (top level of the assembly).&amp;nbsp; By context I mean the 3D coordinate system space of a specific ComponentDefinition.&amp;nbsp; If you are working with measurements, constraints, or any other inter component geometry relationships, then context is very important because both objects need to be in the same context for these types of actions to work.&amp;nbsp; Also, iterating components (instead of iterating referenced documents) is the only way to control inter component context needed for those types of tasks.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 15:24:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12643424#M12382</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-03-15T15:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get all occurrences (ipts, iams) from all levels in top assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12708659#M12383</link>
      <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the late reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, thank you all for your suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7946284"&gt;@A.Acheson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used a little bit simpler approach. I will explain it below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5289378"&gt;@Frederick_Law&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The thing is, I also need assemblies in the collection, not just parts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am coloring them with specific colors, depended on which type of the custom property it has. It can be either IPT or IAM, so that why I need the whole collection.&lt;/P&gt;&lt;P&gt;This was the biggest challenge, on how to get whole collection from the top assembly. The struggles I encountered was that I was not able to get occurrences from sub-assemblies or I did get the occurrences, but not the assemblies.&lt;/P&gt;&lt;P&gt;Thank you for the explanation. I did not exacly try this as you suggested. I used a different approach explained below.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Used approach:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I did it in 2 steps. 1st step was to get all referenced documents from the top assembly, so that all IPTs and IAMs are included. When I had this collection, I iterated through all of them and filtered the needed ones out and used them later in code.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;Rene Repina&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 07:06:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-all-occurrences-ipts-iams-from-all-levels-in-top-assembly/m-p/12708659#M12383</guid>
      <dc:creator>ReneRepina</dc:creator>
      <dc:date>2024-04-15T07:06:14Z</dc:date>
    </item>
  </channel>
</rss>

