<?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: Giving an attribute (name) to the face with largest area using iLogic in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399482#M33320</link>
    <description>&lt;P&gt;The code will only work if the attribute set is not created jet. That means it probably only runs once. Did you check if the attribute was created? (A good tool for that is the &lt;A href="https://ekinssolutions.com/nifty_attributes/" target="_blank" rel="noopener"&gt;Nifty Attributes addin&lt;/A&gt; from &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt; )&lt;/P&gt;</description>
    <pubDate>Sat, 03 Sep 2022 19:54:52 GMT</pubDate>
    <dc:creator>JelteDeJong</dc:creator>
    <dc:date>2022-09-03T19:54:52Z</dc:date>
    <item>
      <title>Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11398669#M33316</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on complex design automation. As I am working through the problem, I realize I need to detect the largest face of my part and give it a name (attribute). Once the name is given to that face, I can use the 'Angle' measure snippet to measure the angle between that face and one of the origin planes. And then continue with the rest of the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone here knows how to make this or points to a resource where I can find some guidance, it will be greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 00:17:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11398669#M33316</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2022-09-03T00:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11398976#M33317</link>
      <description>&lt;P&gt;is this what you are looking for:&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;		Dim doc As PartDocument = ThisDoc.Document
		Dim bodies = doc.ComponentDefinition.SurfaceBodies

		Dim biggestFaceArea As Double = Double.MinValue
		Dim biggestFace As Face = Nothing
		For Each body As SurfaceBody In bodies
			For Each face As Face In body.Faces
				Dim area = face.Evaluator.Area
				If (biggestFaceArea &amp;lt; area) Then
					biggestFace = face
					biggestFaceArea = area
				End If
			Next
		Next

		Dim attSet = biggestFace.AttributeSets.Add("hjalte.nl")
		Dim att = attSet.Add("biggest", ValueTypeEnum.kDoubleType, biggestFaceArea)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 03 Sep 2022 08:55:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11398976#M33317</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-09-03T08:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11398993#M33318</link>
      <description>&lt;P&gt;Just because it can be done. It's also possible without loops &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Dim doc As PartDocument = ThisDoc.Document

Dim biggestFace = doc.ComponentDefinition.SurfaceBodies.
	Cast(Of SurfaceBody).
	SelectMany(Of Face)(Function(f) f.Faces.Cast(Of Face)).
	Aggregate(Function(face, nextFace) If(face.Evaluator.Area &amp;gt; nextFace.Evaluator.Area, face, nextFace))


Dim attSet = biggestFace.AttributeSets.Add("hjalte.nl")
Dim att = attSet.Add("biggest", ValueTypeEnum.kDoubleType, biggestFace.Evaluator.Area)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 09:29:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11398993#M33318</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-09-03T09:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399436#M33319</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5011186"&gt;@JelteDeJong&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for taking the time and helping me with this problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried running your code but for some reason, I'm getting an error on this line:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim attSet = biggestFace.AttributeSets.Add("hjalte.nl")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried following the method described on this blog (link at the btm), and it looks like I'm getting similar errors when trying to add an Attribute to the part using the code from it. It says the parameter is incorrect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="frahaman7SKBG_0-1662230910499.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1111376i699AE44057DD9B95/image-size/medium?v=v2&amp;amp;px=400" role="button" title="frahaman7SKBG_0-1662230910499.png" alt="frahaman7SKBG_0-1662230910499.png" /&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;Blog:&amp;nbsp;&lt;A href="https://modthemachine.typepad.com/my_weblog/2009/07/introduction-to-attributes.html" target="_blank" rel="noopener"&gt;https://modthemachine.typepad.com/my_weblog/2009/07/introduction-to-attributes.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 18:49:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399436#M33319</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2022-09-03T18:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399482#M33320</link>
      <description>&lt;P&gt;The code will only work if the attribute set is not created jet. That means it probably only runs once. Did you check if the attribute was created? (A good tool for that is the &lt;A href="https://ekinssolutions.com/nifty_attributes/" target="_blank" rel="noopener"&gt;Nifty Attributes addin&lt;/A&gt; from &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt; )&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 19:54:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399482#M33320</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-09-03T19:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399490#M33321</link>
      <description>&lt;P&gt;You are correct, it does look like the attribute was created. I was able to check using the code below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does the attribute not appear under the Entities list in the iLogic browser? When I tried calling the attribute for my next calculation, it said the Entity was not found.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Isn't the Attribute and Entity the same thing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="frahaman7SKBG_0-1662236072171.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1111384i3C4963882473D684/image-size/medium?v=v2&amp;amp;px=400" role="button" title="frahaman7SKBG_0-1662236072171.png" alt="frahaman7SKBG_0-1662236072171.png" /&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;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;    Dim doc As Document
    doc = ThisApplication.ActiveDocument 

    ' Get the attribute manager.
    Dim attribMgr As AttributeManager
   attribMgr = doc.AttributeManager

    ' Find all attribute sets named "SampleSet".
    Dim foundEntities As ObjectCollection
  	foundEntities = attribMgr.FindObjects("hjalte.nl")

    MsgBox ("Found" &amp;amp;foundEntities.Count &amp;amp; " entities.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 20:15:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399490#M33321</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2022-09-03T20:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399502#M33322</link>
      <description>&lt;P&gt;Entities are attributes with special (set)names.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JelteDeJong_0-1662237381536.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1111385iD088DA4A7CA7939D/image-size/large?v=v2&amp;amp;px=999" role="button" title="JelteDeJong_0-1662237381536.png" alt="JelteDeJong_0-1662237381536.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 20:37:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399502#M33322</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-09-03T20:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399750#M33323</link>
      <description>&lt;P&gt;I think I might have explained my problem incorrectly in the initial post. I want to use iLogic to inspect the model and Assign Entity Name on the biggest face. So instead of right click and 'Assign Entity Name', I want to do that with iLogic. Is that possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="frahaman7SKBG_0-1662263918328.png" style="width: 393px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1111404iEE59A19896391B3F/image-dimensions/393x282?v=v2" width="393" height="282" role="button" title="frahaman7SKBG_0-1662263918328.png" alt="frahaman7SKBG_0-1662263918328.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2022 03:59:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11399750#M33323</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2022-09-04T03:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11400172#M33324</link>
      <description>&lt;P&gt;Oke creating entities is a bit more difficult. The script below will do it for you. Be aware that the entity is created but not directly visible. In some cases, you need to save and reopen the file. The script might also not work with faces of sheet metal features. If that is the case then you need to alter the script a bit to also loop over all sheet metal features while searching for the face.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Dim doc As PartDocument = ThisDoc.Document

Dim biggestFace = doc.ComponentDefinition.SurfaceBodies.
    Cast(Of SurfaceBody).
    SelectMany(Of Face)(Function(f) f.Faces.Cast(Of Face)).
    Aggregate(Function(face, nextFace) If(face.Evaluator.Area &amp;gt; nextFace.Evaluator.Area, face, nextFace))

Dim nameOfYourFace = "www.hjalte.nl"
Dim attSetName = "iLogicEntityNameSet"
Dim attName = "iLogicEntityName"
Dim attNameFeatureName = "iLogicEntityNameFeatureName"
Dim EntityNameSet = "iLogicEntityNameSet"
Dim entityNamesOrdered = "iLogicEntityNamesOrdered"

' Create Name attribute
Dim attSet As AttributeSet
If (biggestFace.AttributeSets.NameIsUsed(attSetName)) Then
    attSet = biggestFace.AttributeSets.Item(attSetName)
Else
    attSet = biggestFace.AttributeSets.Add(attSetName)
End If

If (attSet.NameIsUsed(attName)) Then
    attSet.Item(attName).Value = nameOfYourFace
Else
    attSet.Add(attName, ValueTypeEnum.kStringType, nameOfYourFace)
End If

' Create Feature attribute
Dim feature = Nothing
For Each cFeature As PartFeature In doc.ComponentDefinition.Features
    If cFeature.Faces Is Nothing Then Continue For
    For Each cFace As Face In cFeature.Faces
        If (biggestFace Is cFace) Then
            feature = cFeature
        End If
    Next
Next

Dim lCont As Long = doc.ReferenceKeyManager.CreateKeyContext()
Dim bKey() As Byte = New Byte() {}
feature.GetReferenceKey(bKey, lCont)
Dim strKey As String = doc.ReferenceKeyManager.KeyToString(bKey)

If (attSet.NameIsUsed(attNameFeatureName)) Then
    attSet.Item(attNameFeatureName).Value = strKey
Else
    attSet.Add(attNameFeatureName, ValueTypeEnum.kStringType, strKey)
End If

' Add entity to list of entities.

If (doc.AttributeSets.NameIsUsed(EntityNameSet)) Then
    attSet = doc.AttributeSets.Item(EntityNameSet)
Else
    attSet = doc.AttributeSets.Add(EntityNameSet)
End If

If (attSet.NameIsUsed(entityNamesOrdered)) Then
    Dim nameListString As String = attSet.Item(entityNamesOrdered).Value

    If (Not nameListString.Contains(nameOfYourFace)) Then
        nameListString = nameListString.Trim()
        Dim ents = nameListString.Split(vbTab).ToList()
        ents.Add(nameOfYourFace)
        attSet.Item(entityNamesOrdered).Value = String.Join(vbTab, ents)
    End If
Else
    attSet.Add(entityNamesOrdered, ValueTypeEnum.kStringType, nameOfYourFace)
End If&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2022 15:34:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11400172#M33324</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-09-04T15:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Giving an attribute (name) to the face with largest area using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11400589#M33325</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5011186"&gt;@JelteDeJong&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 00:23:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/giving-an-attribute-name-to-the-face-with-largest-area-using/m-p/11400589#M33325</guid>
      <dc:creator>frahaman7SKBG</dc:creator>
      <dc:date>2022-09-05T00:23:20Z</dc:date>
    </item>
  </channel>
</rss>

