<?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: Mating with .NET and Named Faces in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9710914#M115081</link>
    <description>&lt;P&gt;Here's some quickie code using 'NamedEntities', you may find useful in this situation.&amp;nbsp; It's likely much easier to use the 'NamedEntities' than it is to search through all the Attributes to find the right one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;'oDoc can be either the active document,
'or the Document of a ComponentOccurrence in an assembly,
'or the oRefDoc of the assembly's AllReferencedDocuments.
Dim oNEntities As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oMap As NameValueMap = oNEntities.Entities

'You can define these objects as whatever type of object they really are instead of just Object
Dim oObj1 As Object
Try
	oObj1 = oNEntities.FindEntity("Name")
Catch
	MsgBox("Coundn't find an entity in that document with that name.")
End Try
Dim oName As String = oNEntities.GetName(oEntity)
If oNEntities.NameExists("Name") Then
	MsgBox("That names exists.")
End If
oNEntities.SetName(oEntity, "Name")

'This is the same as FindEntity, but can return Nothing instead of an Exception.
Dim oObj2 As Object = oNEntities.TryGetEntity("Name")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Aug 2020 15:30:15 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2020-08-25T15:30:15Z</dc:date>
    <item>
      <title>Mating with .NET and Named Faces</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9710844#M115080</link>
      <description>&lt;P&gt;I am trying to programmatically mate parts using VB.NET. All of the examples I have found involve the user selecting the faces or other elements that want to be mated as part of the program. I am hoping to instead do it fully programmatically but I don't see any examples of how this can be done. I have tried using the "Assign Name" function and then referencing that later on, but I don't see the AttributeSet show up in the assembly under the component occurrence, only in the part file itself. Does anyone have a recommendation for how I can name a few faces for a part and then programmatically mate them and whatnot inside of an assembly? Thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 14:59:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9710844#M115080</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-25T14:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Mating with .NET and Named Faces</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9710914#M115081</link>
      <description>&lt;P&gt;Here's some quickie code using 'NamedEntities', you may find useful in this situation.&amp;nbsp; It's likely much easier to use the 'NamedEntities' than it is to search through all the Attributes to find the right one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;'oDoc can be either the active document,
'or the Document of a ComponentOccurrence in an assembly,
'or the oRefDoc of the assembly's AllReferencedDocuments.
Dim oNEntities As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oMap As NameValueMap = oNEntities.Entities

'You can define these objects as whatever type of object they really are instead of just Object
Dim oObj1 As Object
Try
	oObj1 = oNEntities.FindEntity("Name")
Catch
	MsgBox("Coundn't find an entity in that document with that name.")
End Try
Dim oName As String = oNEntities.GetName(oEntity)
If oNEntities.NameExists("Name") Then
	MsgBox("That names exists.")
End If
oNEntities.SetName(oEntity, "Name")

'This is the same as FindEntity, but can return Nothing instead of an Exception.
Dim oObj2 As Object = oNEntities.TryGetEntity("Name")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 15:30:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9710914#M115081</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-08-25T15:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Mating with .NET and Named Faces</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9711048#M115084</link>
      <description>&lt;P&gt;Hi @Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From what I can tell, you can only name faces in parts, not assemblies. I guess because the faces doesn't really exist in the assembly. Whenever you work with a face on assembly level Inventor actually creates a proxy for that face through the occurrence. So we have to find the named face in the part, then create a proxy for it and then use it in the Mate constraint.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See example below. I've placed two occurrences of the same part (Part5). So the occurrences are called Part5:1 and Part5:2. I use the document from one of the occurrences to get the Face in the part named "Mate1". Then I create proxies for that face for each part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then use these proxies to constrain the faces together &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #ff0000;"&gt;Sub&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Main&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oAsm&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800080;"&gt;Document&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oAsmDef&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;AssemblyComponentDefinition&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;oAsm&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN style="color: #808080;"&gt;'Get the occurrences&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oOcc1&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;ComponentOccurrence&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;oAsmDef&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Occurrences&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"Part5:1"&lt;/SPAN&gt;)
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oOcc2&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;ComponentOccurrence&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;oAsmDef&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Occurrences&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;ItemByName&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"Part5:2"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;'Find the named face (object in part document)&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oFace&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Face&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;GetNamedEntity&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;oOcc1&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Definition&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Document&lt;/SPAN&gt;, &lt;SPAN style="color: #008080;"&gt;"Mate1"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;'Create Proxies for that face through each of the occurrences.&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oFaceProx1&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;FaceProxy&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oFaceProx2&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;FaceProxy&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;oOcc1&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;CreateGeometryProxy&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;oFace&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;oFaceProx1&lt;/SPAN&gt;)
&lt;SPAN style="color: #800000;"&gt;oOcc2&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;CreateGeometryProxy&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;oFace&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;oFaceProx2&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;'Create a mate constraint&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;oAsmDef&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Constraints&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;AddMateConstraint&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;oFaceProx1&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;oFaceProx2&lt;/SPAN&gt;, 0)
&lt;SPAN style="color: #ff0000;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Sub&lt;/SPAN&gt;

&lt;SPAN style="color: #ff0000;"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Function&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;GetNamedEntity&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;doc&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Document&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;name&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;String&lt;/SPAN&gt;) &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Object&lt;/SPAN&gt;
    &lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;attribMgr&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;AttributeManager&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;doc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;AttributeManager&lt;/SPAN&gt;
    &lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;objsFound&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;ObjectCollection&lt;/SPAN&gt;
    &lt;SPAN style="color: #800000;"&gt;objsFound&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;attribMgr&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;FindObjects&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"iLogicEntityNameSet"&lt;/SPAN&gt;, &lt;SPAN style="color: #008080;"&gt;"iLogicEntityName"&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;name&lt;/SPAN&gt;)
    
    &lt;SPAN style="color: #ff0000;"&gt;If&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;objsFound&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Count&lt;/SPAN&gt; &amp;gt; 0 &lt;SPAN style="color: #ff0000;"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN style="color: #ff0000;"&gt;Return&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;objsFound&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Item&lt;/SPAN&gt;(1))
    &lt;SPAN style="color: #ff0000;"&gt;Else&lt;/SPAN&gt;
        &lt;SPAN style="color: #ff0000;"&gt;Return&lt;/SPAN&gt;(&lt;SPAN style="color: #ff0000;"&gt;Nothing&lt;/SPAN&gt;)
    &lt;SPAN style="color: #ff0000;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;If&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Function&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll also attach the assembly with this post (Inv 2020).&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 16:21:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9711048#M115084</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2020-08-25T16:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Mating with .NET and Named Faces</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9711507#M115098</link>
      <description>&lt;P&gt;Thank you both for the support and the quick responses.&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5330176"&gt;@JhoelForshav&lt;/a&gt;&amp;nbsp; provided the exact code I needed to resolve my issue and a great explanation. Thank you very much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 19:53:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/mating-with-net-and-named-faces/m-p/9711507#M115098</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-25T19:53:12Z</dc:date>
    </item>
  </channel>
</rss>

