<?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: List occurrences in specific SubAssembly in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11256771#M35625</link>
    <description>&lt;P&gt;Thanks a bunch! This seems to get me going again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get each oOcc's full file name, previously I've used something like&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oDoc as Document = oOcc.Definition.Document
oDoc.FullFileName&lt;/LI-CODE&gt;&lt;P&gt;But when I use this in the context of "SubOcc", I get the error:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(Exception from HRESULT: 0x80004005 (E_FAIL))&lt;/LI-CODE&gt;&lt;P&gt;I've looked into the error but can't find a clear answer as to what to do to fix this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know how i can get access to each oOcc's FullFileName and information such as that?&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jun 2022 15:14:46 GMT</pubDate>
    <dc:creator>viktor.borgen</dc:creator>
    <dc:date>2022-06-24T15:14:46Z</dc:date>
    <item>
      <title>List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11256004#M35623</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on an iLogic rule to replace components from an Assembly with components found in Vault.&lt;/P&gt;&lt;P&gt;So far I've gotten it to search for either top-level components or LeafOccurrences, and replace those it finds with the Vault versions.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="viktorborgen_0-1656060909344.png" style="width: 300px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1083739i3E276D27A1C8BA8F/image-size/small?v=v2&amp;amp;px=200" role="button" title="viktorborgen_0-1656060909344.png" alt="viktorborgen_0-1656060909344.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My screenshot shows the model tree after I've run the rule, this is how far I've managed to get.&lt;/P&gt;&lt;P&gt;As shown in the screenshot, all the top-level parts and Subassemblies have been replaced. The Subassembly named "352135:1" is one which was not found in Vault. A copy has been made and given a Vault number, and the original part has been replaced with the copy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now need to figure out how to replace the parts of&amp;nbsp;"352135:1" by iLogic. I have tried to replace all LeafOccurrences, but some other subassemblies contain their own subassemblies, and i want to replace those before their leaves.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the parts of the Subassembly&amp;nbsp;"352135:1" either exist in Vault and can be downloaded by search, or can be copied locally and used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been at this for a few days now, and everything i try results in errors or just won't compile. Am I complicating this more than I need? If so, what can i do to get these files replaced?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As stated, I've been able to make copies and search the Vault, so the only thing i need is to access the occurrences in this specific subassembly by code, everything else I think I can handle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 08:58:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11256004#M35623</guid>
      <dc:creator>viktor.borgen</dc:creator>
      <dc:date>2022-06-24T08:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11256381#M35624</link>
      <description>&lt;P&gt;You can use something like this. When you run into an assembly (with sub occurrences) it calls to another sub.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oAss&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;
&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oAss&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;Occurrences&lt;/SPAN&gt;
	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Suppressed&lt;/SPAN&gt; = &lt;SPAN&gt;False&lt;/SPAN&gt;
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;SubOccurrences&lt;/SPAN&gt;.&lt;SPAN&gt;Count&lt;/SPAN&gt; &amp;gt; 0
			&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;SubOccs&lt;/SPAN&gt;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t;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 12:31:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11256381#M35624</guid>
      <dc:creator>dalton98</dc:creator>
      <dc:date>2022-06-24T12:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11256771#M35625</link>
      <description>&lt;P&gt;Thanks a bunch! This seems to get me going again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get each oOcc's full file name, previously I've used something like&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oDoc as Document = oOcc.Definition.Document
oDoc.FullFileName&lt;/LI-CODE&gt;&lt;P&gt;But when I use this in the context of "SubOcc", I get the error:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(Exception from HRESULT: 0x80004005 (E_FAIL))&lt;/LI-CODE&gt;&lt;P&gt;I've looked into the error but can't find a clear answer as to what to do to fix this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know how i can get access to each oOcc's FullFileName and information such as that?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 15:14:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11256771#M35625</guid>
      <dc:creator>viktor.borgen</dc:creator>
      <dc:date>2022-06-24T15:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11257057#M35626</link>
      <description>&lt;P&gt;That should work. Are you just using 'oDoc.FullFileName' or are you assigning a variable to it? ' oFileName = oDoc.FullFileName'. I would need more info on which parts are giving you that error.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 17:57:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11257057#M35626</guid>
      <dc:creator>dalton98</dc:creator>
      <dc:date>2022-06-24T17:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11257817#M35627</link>
      <description>&lt;P&gt;The code I've written thus far goes through all top-level components (both assy and parts) and get the value of their custom iProperties I use to search for parts in Vault.&lt;/P&gt;&lt;P&gt;I don't really know if I need it, but at the same time the iProps are gathered, the code gathers their oDoc.FullFileName.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The loop I've used for this is set up like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;For Each oCompOcc In oCompOccs
	
	oDoc = oCompOcc.Definition.Document
	Try
		iLogicTypeArray.Add(iProperties.Value(oCompOcc.Name, "Custom", "iLogic_Type"))
		iLogicParameterArray.Add(iProperties.Value(oCompOcc.Name, "Custom", "iLogic_Parameter"))
		OccurrenceNameArray.Add(oCompOcc.Name)
		OccurrenceFileArray.Add(oDoc.FullFileName)
		FullFileNameArray.Add(oDoc.FullFileName)
	Catch
	End Try
	
Next&lt;/LI-CODE&gt;&lt;P&gt;This has worked well untill now, and I think it has something to do with the code in your example needing to run through the loop more than once. I'm not too sure what might be wrong, but it seems it has something to do with the call back to your SubOccs:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If oOcc.Suppressed = False
	If oOcc.SubOccurrences.Count &amp;gt; 0
		Call SubOccs(oOcc)
	End If
End If&lt;/LI-CODE&gt;&lt;P&gt;When oOcc is sent back to SubOccs, I think it brings with it the previously declared&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oDoc = oOcc.Definition.Document&lt;/LI-CODE&gt;&lt;P&gt;But at this point this needs to be (at least i think) something like&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oDoc = oOcc.SubOccurrences.DefinitionDocument&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure this makes too much sense, I'm already getting confused by this.&lt;/P&gt;&lt;P&gt;Hopefully you understand my issue and are able to help.&lt;/P&gt;&lt;P&gt;If you need my full code I can see if I can clean it up a bit and send it over.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 05:58:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11257817#M35627</guid>
      <dc:creator>viktor.borgen</dc:creator>
      <dc:date>2022-06-25T05:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11257819#M35628</link>
      <description>&lt;P&gt;OK&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11795854"&gt;@dalton98&lt;/a&gt;. I found something i feel might be of note.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i first tried adding the&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oDoc = oOcc.Definition.Document&lt;/LI-CODE&gt;&lt;P&gt;to the code you sent, I got the error i mentioned earlier. This was when this declaration happened inside the for-loop in SubOccs. I just now tried declaring it on the outside of that loop, and that seems to work, not giving any errors.&lt;/P&gt;&lt;P&gt;I'm happy to use it like that, but do you have any idea what is happening? Would love to understand this error better, as I'm sure it might arise later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error does not show when declaring the oDoc inside the for-loop if the loop is only run once. The moment it runs again the whole rule stops with the cryptic error...&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 06:04:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11257819#M35628</guid>
      <dc:creator>viktor.borgen</dc:creator>
      <dc:date>2022-06-25T06:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11260794#M35629</link>
      <description>&lt;P&gt;I think the problem is you are not calling the arrays to the 'SubOcc' sub. Imagine each sub as its own code, and if you do not pass information between them then it will not recognize information for the other sub. You would set it up like this:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;SubOccs&lt;/SPAN&gt;(&lt;SPAN&gt;oOcc, iLogicTypeArray, iLogicParameterArray, etc....)&lt;BR /&gt;&lt;BR /&gt;Sub SubOccs(oOcc as ComponentOccurrence, iLogicTypeArray as ArrayList, iLogicParameterArray as ArrayList)&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2022 12:25:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11260794#M35629</guid>
      <dc:creator>dalton98</dc:creator>
      <dc:date>2022-06-27T12:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: List occurrences in specific SubAssembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11262764#M35630</link>
      <description>&lt;P&gt;Yeah I'm sure it has something to do with when information is accessed and what information is sent.&lt;/P&gt;&lt;P&gt;I got it to work tho, it seems i had forgotten to declare/update the oDoc variable before sending it back to the recursive sub. Everything seems to work as it should now, all issues I have now are issues I know I've created and believe I can resolve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm marking your first response as a solution, as it was with that i resolved it! Thanks a bunch!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 05:19:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/list-occurrences-in-specific-subassembly/m-p/11262764#M35630</guid>
      <dc:creator>viktor.borgen</dc:creator>
      <dc:date>2022-06-28T05:19:44Z</dc:date>
    </item>
  </channel>
</rss>

