<?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: Instantiating SubOccurances in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3110152#M139690</link>
    <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="1"&gt;Chris,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="1"&gt;It looks like you only left out one small detail, the occurrence name is the document name and also the instance of that document. For example, if you have your subassembly named "Control R7﻿" you could reference it like this:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;Dim aDoc As Inventor.AssemblyDocument = m_inventorApplication.ActiveDocument &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;Dim iOcc As ComponentOccurrence = aDoc.ComponentDefinition.Occurrences.ItemByName("Control R7﻿:1")&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;'...&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;End If﻿&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333" size="1" face="arial,helvetica,sans-serif"&gt;&lt;SPAN style="line-height: 13px;"&gt;As far as I know, you need to do it this way to use ItemByName.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333" size="1" face="arial,helvetica,sans-serif"&gt;&lt;SPAN style="line-height: 13px;"&gt;Regards,&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333" size="1" face="arial,helvetica,sans-serif"&gt;Nelson&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2011 05:37:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-08-01T05:37:08Z</dc:date>
    <item>
      <title>Instantiating SubOccurances</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3109820#M139689</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps I've been looking at this for too long, but I can't figure out why I can't get a reference to a subOccurance by name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying to get a reference for the Sub-Assembly named 'Control R7' using&amp;nbsp;the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            'Set a reference to the active document.
            oInvAssyDoc = oInvApp.ActiveDocument

            'Set a reference to an active assembly component definition.
            oInvAssyCompDef = oInvAssyDoc.ComponentDefinition

            'Set a reference to the occurances in the component definition.
            oInvAssyCompOccs = oInvAssyCompDef.Occurrences

            'Create a reference to the 'Markers' ComponentOccurance.
            Dim location_markers_left_occ As Inventor.ComponentOccurrence = oInvAssyCompOccs.ItemByName("Location Markers Left")

            ' Get a reference to the Location Markers Left Component Occurances.
            Dim lm_left_sub_occs As Inventor.ComponentOccurrences = location_markers_left_occ.SubOccurrences

            ' Get a reference to the occurance named 'Control R7'
            Dim control_left As Inventor.ComponentOccurrence = lm_left_sub_occs.ItemByName("Control R7")&lt;/PRE&gt;&lt;P&gt;This does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However if I loop through the occurances in lm_left_sub_occs I can set control_left as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            For Each comp_occ As Inventor.ComponentOccurrence In lm_left_sub_occs

                If comp_occ.Name = ("Control R7") Then
                    Console.WriteLine("Control R7 is here!")
                    control_left = comp_occ
                End If

            Next&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Can anyone please explain why I can't access the occurance by name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2011 22:35:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3109820#M139689</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-30T22:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating SubOccurances</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3110152#M139690</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="1"&gt;Chris,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="1"&gt;It looks like you only left out one small detail, the occurrence name is the document name and also the instance of that document. For example, if you have your subassembly named "Control R7﻿" you could reference it like this:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;If m_inventorApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;Dim aDoc As Inventor.AssemblyDocument = m_inventorApplication.ActiveDocument &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;Dim iOcc As ComponentOccurrence = aDoc.ComponentDefinition.Occurrences.ItemByName("Control R7﻿:1")&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;'...&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" size="1" face="arial,helvetica,sans-serif"&gt;End If﻿&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333" size="1" face="arial,helvetica,sans-serif"&gt;&lt;SPAN style="line-height: 13px;"&gt;As far as I know, you need to do it this way to use ItemByName.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333" size="1" face="arial,helvetica,sans-serif"&gt;&lt;SPAN style="line-height: 13px;"&gt;Regards,&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333" size="1" face="arial,helvetica,sans-serif"&gt;Nelson&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2011 05:37:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3110152#M139690</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-01T05:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating SubOccurances</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3111000#M139691</link>
      <description>&lt;P&gt;Thank you for your thoughts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be clear I have named the Occurance 'Control R7' in the Browser. I know that the name is this because if I iterate through all occurances in the parent assembly looking for 'Control R7' I find it and can create a reference to it. I can't see why I can't simply get the item by name from the parent's&amp;nbsp;occurances.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2011 21:28:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3111000#M139691</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-01T21:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating SubOccurances</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3111036#M139692</link>
      <description>&lt;P&gt;Ok, I didn't realized you had renamed it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My next thought would be, if oInvApp.ActiveDocument is the Parent of Control R7 then why can't you just do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oInvAssyDoc = oInvApp.ActiveDocument﻿&lt;/P&gt;&lt;P&gt;﻿oInvAssyCompDef = oInvAssyDoc.ComponentDefinition﻿&lt;/P&gt;&lt;P&gt;oInvAssyCompOccs = oInvAssyCompDef.Occurrences﻿&lt;/P&gt;&lt;P&gt;Dim control_left As Inventor.ComponentOccurrence = oInvAssyCompOccs.ItemByName("Control R7")﻿&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2011 22:17:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3111036#M139692</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-01T22:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating SubOccurances</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3111982#M139693</link>
      <description>&lt;P&gt;The assembly which I want to get a reference to so that I can set its Visible property, which I have named 'Control R7', is within an assembly named 'Location Markers Left' which is within the top level assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought I should:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Get a reference of the occurances in the top level componentDefinition.&lt;/LI&gt;&lt;LI&gt;Get a reference of the itemByName 'Location Markers Left' in the top level occurances.&lt;/LI&gt;&lt;LI&gt;Get a reference of the subOccurances of 'Location Markers Left'.&lt;/LI&gt;&lt;LI&gt;Get a reference of the itemByName 'Control R7' in the subOccurances.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'Set a reference to the active document.
oInvAssyDoc = oInvApp.ActiveDocument

'Set a reference to an active assembly component definition.
oInvAssyCompDef = oInvAssyDoc.ComponentDefinition

'Set a reference to the occurances in the component definition.
oInvAssyCompOccs = oInvAssyCompDef.Occurrences

'Create a reference to the 'Markers' ComponentOccurance.
Dim location_markers_left_occ As Inventor.ComponentOccurrence = oInvAssyCompOccs.ItemByName("Location Markers Left")

' Get a reference to the Location Markers Left Component Occurances.
Dim lm_left_sub_occs As Inventor.ComponentOccurrences = location_markers_left_occ.SubOccurrences

' Get a reference to the occurance named 'Control R7'
Dim control_left As Inventor.ComponentOccurrence = lm_left_sub_occs.ItemByName("Control R7")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This just gives me an error: System.NotImplementedException: Not implemented (Exception from HRESULT: 0x800040001 (E_NOTIMPL))...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Curiously though if I replace the itemByName statement and&amp;nbsp;iterate through the same reference to the subOccurances testing the Name property for 'Control R7' it is found and the reference created!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;For Each comp_occ As Inventor.ComponentOccurrence In lm_left_sub_occs

  Select Case comp_occ.Name

    ' R7
    Case "Control R7"
    control_left = comp_occ

  End Select

Next&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is it me or is that odd? I must be missing something obvious.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2011 09:23:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3111982#M139693</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-03T09:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Instantiating SubOccurances</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3112696#M139694</link>
      <description>&lt;P&gt;Hmmm, it looks like the problem could be in the '.suboccurrence' part. I think that isn't going to return what you want.&lt;/P&gt;&lt;P&gt;I made a small change, see if this works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;'Set a reference to the active document.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;oInvAssyDoc = oInvApp.ActiveDocument&lt;BR /&gt;'Set a reference to an active assembly component definition.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;oInvAssyCompDef = oInvAssyDoc.ComponentDefinition&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Set a reference to the occurances in the component definition.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;oInvAssyCompOccs = oInvAssyCompDef.Occurrences&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;'Create a reference to the 'Markers' ComponentOccurance.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim location_markers_left_occ As Inventor.ComponentOccurrence = oInvAssyCompOccs.ItemByName("Location Markers Left")&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;' Get a reference to the occurance named 'Control R7'&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim control_left As Inventor.ComponentOccurrence = location_markers_left_occ.Definition.Occurrences.ItemByName("Control R7")﻿&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2011 19:04:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/instantiating-suboccurances/m-p/3112696#M139694</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-03T19:04:54Z</dc:date>
    </item>
  </channel>
</rss>

