<?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 AddUsingiMates in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/addusingimates/m-p/10142857#M52288</link>
    <description>&lt;P&gt;Hey&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am adding Components to my assembly then calling an iMates function to constrain them. I was looking at the AddUsingiMates function as its much faster but i cant see how i can declare the specific components to be mated. Is it feasible to do that? It looks like the AddUsingiMates will match the first set of iMates found...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reason: i have different components with iMates and based on certain conditions, a typical component will need to be added. The typical component will be mated with the relevant components if the condition is met but only if the condition is met hence the declaring of the mating component.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current code is set up so i can pass the AssemblyDefinition, First &amp;amp; Second occurrences along with an index of each iMate. It works fine, id just like to narrow down my code and speed up where possible..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my iMates code&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Friend Sub DoiMates(ByVal BaseComponent As ComponentOccurrence, ByVal BP1 As Integer, ByVal BP2 As Integer, ByVal BP3 As Integer,
                        ByVal SecondComponent As ComponentOccurrence, ByVal SP1 As Integer, ByVal SP2 As Integer, ByVal SP3 As Integer,
                        ByVal Assy As AssemblyComponentDefinition)

Dim Bcd As iMateDefinitionsEnumerator = BaseComponent.iMateDefinitions
Dim Scd As iMateDefinitionsEnumerator = SecondComponent.iMateDefinitions
Dim oiMateResults As iMateResult = Nothing
Try
   oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP1), Scd.Item(SP1))
Catch ex As Exception
End Try

Try
    oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP2), Scd.Item(SP2))
Catch ex As Exception
End Try

Try
   oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP3), Scd.Item(SP3))
Catch ex As Exception
End Try
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Called like this&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IC.DoiMates(_BaseModel, 2, 3, 4, oCompOcc, 2, 3, 5, _aDef)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AddUsingiMates would be a single line of code, much more efficient but only if the 2 components were able to be declared..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions? Even on improving my code? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 09 Mar 2021 18:25:25 GMT</pubDate>
    <dc:creator>NachoShaw</dc:creator>
    <dc:date>2021-03-09T18:25:25Z</dc:date>
    <item>
      <title>AddUsingiMates</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/addusingimates/m-p/10142857#M52288</link>
      <description>&lt;P&gt;Hey&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am adding Components to my assembly then calling an iMates function to constrain them. I was looking at the AddUsingiMates function as its much faster but i cant see how i can declare the specific components to be mated. Is it feasible to do that? It looks like the AddUsingiMates will match the first set of iMates found...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reason: i have different components with iMates and based on certain conditions, a typical component will need to be added. The typical component will be mated with the relevant components if the condition is met but only if the condition is met hence the declaring of the mating component.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current code is set up so i can pass the AssemblyDefinition, First &amp;amp; Second occurrences along with an index of each iMate. It works fine, id just like to narrow down my code and speed up where possible..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my iMates code&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Friend Sub DoiMates(ByVal BaseComponent As ComponentOccurrence, ByVal BP1 As Integer, ByVal BP2 As Integer, ByVal BP3 As Integer,
                        ByVal SecondComponent As ComponentOccurrence, ByVal SP1 As Integer, ByVal SP2 As Integer, ByVal SP3 As Integer,
                        ByVal Assy As AssemblyComponentDefinition)

Dim Bcd As iMateDefinitionsEnumerator = BaseComponent.iMateDefinitions
Dim Scd As iMateDefinitionsEnumerator = SecondComponent.iMateDefinitions
Dim oiMateResults As iMateResult = Nothing
Try
   oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP1), Scd.Item(SP1))
Catch ex As Exception
End Try

Try
    oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP2), Scd.Item(SP2))
Catch ex As Exception
End Try

Try
   oiMateResults = Assy.iMateResults.AddByTwoiMates(Bcd.Item(BP3), Scd.Item(SP3))
Catch ex As Exception
End Try
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Called like this&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IC.DoiMates(_BaseModel, 2, 3, 4, oCompOcc, 2, 3, 5, _aDef)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AddUsingiMates would be a single line of code, much more efficient but only if the 2 components were able to be declared..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions? Even on improving my code? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 18:25:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/addusingimates/m-p/10142857#M52288</guid>
      <dc:creator>NachoShaw</dc:creator>
      <dc:date>2021-03-09T18:25:25Z</dc:date>
    </item>
  </channel>
</rss>

