<?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: Assign component occurrence to variable in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/assign-component-occurrence-to-variable/m-p/5419119#M121601</link>
    <description>&lt;P&gt;Your advice has helped. Thanks alot.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Nov 2014 21:25:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-11-20T21:25:10Z</dc:date>
    <item>
      <title>Assign component occurrence to variable</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/assign-component-occurrence-to-variable/m-p/5406753#M121599</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying with vb.net to assign a virtual component to a variable. The following code creates the virtual component "Assembly" if it doesn't exists :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim _asmCompDef As AssemblyComponentDefinition&lt;BR /&gt;_asmCompDef = _doc.ComponentDefinition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim identity As Matrix&lt;BR /&gt;identity = _invApp.TransientGeometry.CreateMatrix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim occs As ComponentOccurrence&lt;BR /&gt;occs = _asmCompDef.Occurrences.AddVirtual("Assembly", identity)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know how to assign this virtual component to a variable.&lt;/P&gt;&lt;P&gt;This code creates an error :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim existingOcc As ComponentOccurrence&lt;BR /&gt;existingOcc = _asmCompDef.Occurrences.Item("Assembly")&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;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Nov 2014 09:51:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/assign-component-occurrence-to-variable/m-p/5406753#M121599</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-16T09:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Assign component occurrence to variable</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/assign-component-occurrence-to-variable/m-p/5412889#M121600</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best thing is always to test things in VBA. There you would have got a &lt;STRONG&gt;Type mismatch&lt;/STRONG&gt; error that could have pointed you in the right direction.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Item()&lt;/STRONG&gt; expects a &lt;STRONG&gt;Long&lt;/STRONG&gt; input parameter. You could use &lt;STRONG&gt;ItemByName&lt;/STRONG&gt; instead, but that as well will also need the occurrence counter too, i.e. "Assembly:1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps,&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2014 01:16:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/assign-component-occurrence-to-variable/m-p/5412889#M121600</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2014-11-19T01:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Assign component occurrence to variable</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/assign-component-occurrence-to-variable/m-p/5419119#M121601</link>
      <description>&lt;P&gt;Your advice has helped. Thanks alot.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Nov 2014 21:25:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/assign-component-occurrence-to-variable/m-p/5419119#M121601</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-20T21:25:10Z</dc:date>
    </item>
  </channel>
</rss>

