<?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 How to orient the text along the largest edge in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12655294#M165187</link>
    <description>&lt;P&gt;Wishing everyone a great day!&lt;/P&gt;&lt;P&gt;I ask for advice on how to orient the text along the largest edge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;In wood processing there is a need to control wood grain texture vector in detail. For most of the details, I think the solution is to find the largest face of the detail. Then place the symbol indicating the direction of the material in the text box. The task has been partially solved.&lt;/P&gt;&lt;P&gt;Some examples of code were collected on the forum pages, which provided the following.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;' Get the current details document
Dim oPart As PartDocument = ThisApplication.ActiveDocument

' Get the part component definition
Dim oCompDef As PartComponentDefinition = oPart.ComponentDefinition
 
'Initialize variables to store the largest face and its area
Dim maxFace As Face = Nothing
Dim maxArea As Double = 0.0

' Find the edge with the largest area
For Each oFace As Face In oCompDef.SurfaceBodies.Item(1).Faces
    ' Calculate the face area
    Dim oAreaProps As Double
    oAreaProps = oFace.Evaluator.Area
    ' Check whether the current face is the face with the largest area
    If oAreaProps &amp;gt; maxArea Then
        maxArea = oAreaProps
        maxFace = oFace
    End If
Next

' Create a sketch on the plane of the selected face
Dim oSketch As Sketch = oCompDef.Sketches.Add(maxFace)

' Find the face contour with index 1
Dim oEdgeLoop As EdgeLoop = maxFace.EdgeLoops(1)

' Find the minimum and maximum point of the bounding parallel
Dim oMinPt As Point = oEdgeLoop.RangeBox.MinPoint 
Dim oMaxPt As Point = oEdgeLoop.RangeBox.MaxPoint

' Find the center of the bounding parallelepiped circuit
Dim CenterPt As Point = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)

' Let’s convert the coordinates of the center into the coordinates of the sketch
Dim oTextPt As Point2d = oSketch.ModelToSketchSpace(CenterPt)

'Add text "Largest face" to the sketch center
oText = "↔"
Dim oTextBox As TextBox = oSketch.TextBoxes.AddFitted(oTextPt, oText)

' Set new text height (centimeters)
		oFontSize = 6
		oTextBox.FormattedText = "&amp;lt;StyleOverride FontSize = '" &amp;amp; oFontSize &amp;amp; "'&amp;gt;" &amp;amp; oText &amp;amp; "&amp;lt;/StyleOverride&amp;gt;"
		oTextBox.HorizontalJustification = kAlignTextCenter
		oTextBox.VerticalJustification = kAlignTextUpper

iLogicVb.UpdateWhenDone = True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;What are the ways to orient the text along the largest edge?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 06:44:34 GMT</pubDate>
    <dc:creator>ice_sid</dc:creator>
    <dc:date>2024-03-21T06:44:34Z</dc:date>
    <item>
      <title>How to orient the text along the largest edge</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12655294#M165187</link>
      <description>&lt;P&gt;Wishing everyone a great day!&lt;/P&gt;&lt;P&gt;I ask for advice on how to orient the text along the largest edge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;In wood processing there is a need to control wood grain texture vector in detail. For most of the details, I think the solution is to find the largest face of the detail. Then place the symbol indicating the direction of the material in the text box. The task has been partially solved.&lt;/P&gt;&lt;P&gt;Some examples of code were collected on the forum pages, which provided the following.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;' Get the current details document
Dim oPart As PartDocument = ThisApplication.ActiveDocument

' Get the part component definition
Dim oCompDef As PartComponentDefinition = oPart.ComponentDefinition
 
'Initialize variables to store the largest face and its area
Dim maxFace As Face = Nothing
Dim maxArea As Double = 0.0

' Find the edge with the largest area
For Each oFace As Face In oCompDef.SurfaceBodies.Item(1).Faces
    ' Calculate the face area
    Dim oAreaProps As Double
    oAreaProps = oFace.Evaluator.Area
    ' Check whether the current face is the face with the largest area
    If oAreaProps &amp;gt; maxArea Then
        maxArea = oAreaProps
        maxFace = oFace
    End If
Next

' Create a sketch on the plane of the selected face
Dim oSketch As Sketch = oCompDef.Sketches.Add(maxFace)

' Find the face contour with index 1
Dim oEdgeLoop As EdgeLoop = maxFace.EdgeLoops(1)

' Find the minimum and maximum point of the bounding parallel
Dim oMinPt As Point = oEdgeLoop.RangeBox.MinPoint 
Dim oMaxPt As Point = oEdgeLoop.RangeBox.MaxPoint

' Find the center of the bounding parallelepiped circuit
Dim CenterPt As Point = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)

' Let’s convert the coordinates of the center into the coordinates of the sketch
Dim oTextPt As Point2d = oSketch.ModelToSketchSpace(CenterPt)

'Add text "Largest face" to the sketch center
oText = "↔"
Dim oTextBox As TextBox = oSketch.TextBoxes.AddFitted(oTextPt, oText)

' Set new text height (centimeters)
		oFontSize = 6
		oTextBox.FormattedText = "&amp;lt;StyleOverride FontSize = '" &amp;amp; oFontSize &amp;amp; "'&amp;gt;" &amp;amp; oText &amp;amp; "&amp;lt;/StyleOverride&amp;gt;"
		oTextBox.HorizontalJustification = kAlignTextCenter
		oTextBox.VerticalJustification = kAlignTextUpper

iLogicVb.UpdateWhenDone = True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;What are the ways to orient the text along the largest edge?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 06:44:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12655294#M165187</guid>
      <dc:creator>ice_sid</dc:creator>
      <dc:date>2024-03-21T06:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to orient the text along the largest edge</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656007#M165203</link>
      <description>&lt;P&gt;Could you share some screenshots of the results you need? To see if there are simpler solutions&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 12:00:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656007#M165203</guid>
      <dc:creator>Sergio.D.Suárez</dc:creator>
      <dc:date>2024-03-21T12:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to orient the text along the largest edge</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656235#M165216</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Yeah, here’s an example&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Деталь с текстурой - пример 02.jpg" style="width: 877px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1340020i89B637387BDFDC20/image-dimensions/877x504?v=v2" width="877" height="504" role="button" title="Деталь с текстурой - пример 02.jpg" alt="Деталь с текстурой - пример 02.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 13:28:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656235#M165216</guid>
      <dc:creator>ice_sid</dc:creator>
      <dc:date>2024-03-21T13:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to orient the text along the largest edge</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656551#M165229</link>
      <description>&lt;P&gt;to search the longest edge and rotate the TextBox use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;' search the longest edge&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;maxLen&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;maxEdge&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Edge&lt;/SPAN&gt;
&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oEdge&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Edge&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oEdgeLoop&lt;/SPAN&gt;.&lt;SPAN&gt;Edges&lt;/SPAN&gt;
	&lt;SPAN&gt;eLen&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;MeasureTools&lt;/SPAN&gt;.&lt;SPAN&gt;GetMinimumDistance&lt;/SPAN&gt;(&lt;SPAN&gt;oEdge&lt;/SPAN&gt;.&lt;SPAN&gt;StartVertex&lt;/SPAN&gt;.&lt;SPAN&gt;Point&lt;/SPAN&gt;, &lt;SPAN&gt;oEdge&lt;/SPAN&gt;.&lt;SPAN&gt;StopVertex&lt;/SPAN&gt;.&lt;SPAN&gt;Point&lt;/SPAN&gt;)
	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;eLen&lt;/SPAN&gt; &amp;gt; &lt;SPAN&gt;maxLen&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;maxLen&lt;/SPAN&gt; = &lt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&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oColl&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ObjectCollection&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientObjects&lt;/SPAN&gt;.&lt;SPAN&gt;CreateObjectCollection&lt;/SPAN&gt;() 
&lt;SPAN&gt;oColl&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oTextBox&lt;/SPAN&gt;)
&lt;SPAN&gt;oTextBox&lt;/SPAN&gt;.&lt;SPAN&gt;ShowBoundaries&lt;/SPAN&gt; = &lt;SPAN&gt;True&lt;/SPAN&gt;
&lt;SPAN&gt;oSketch&lt;/SPAN&gt;.&lt;SPAN&gt;RotateSketchObjects&lt;/SPAN&gt;(&lt;SPAN&gt;oColl&lt;/SPAN&gt;, &lt;SPAN&gt;oSketch&lt;/SPAN&gt;.&lt;SPAN&gt;ModelToSketchSpace&lt;/SPAN&gt;(&lt;SPAN&gt;CenterPt&lt;/SPAN&gt;), &lt;SPAN&gt;Ang&lt;/SPAN&gt;, &lt;SPAN&gt;False&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oHin&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Vector2d&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;.&lt;SPAN&gt;CreateVector2d&lt;/SPAN&gt;(1, 0)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oHer&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Vector2d&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;.&lt;SPAN&gt;CreateVector2d&lt;/SPAN&gt;(-1, 0)
&lt;SPAN&gt;oSketch&lt;/SPAN&gt;.&lt;SPAN&gt;MoveSketchObjects&lt;/SPAN&gt;(&lt;SPAN&gt;oColl&lt;/SPAN&gt;, &lt;SPAN&gt;oHin&lt;/SPAN&gt;)
&lt;SPAN&gt;oSketch&lt;/SPAN&gt;.&lt;SPAN&gt;MoveSketchObjects&lt;/SPAN&gt;(&lt;SPAN&gt;oColl&lt;/SPAN&gt;, &lt;SPAN&gt;oHer&lt;/SPAN&gt;)&lt;/PRE&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>Thu, 21 Mar 2024 15:30:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656551#M165229</guid>
      <dc:creator>StKrause</dc:creator>
      <dc:date>2024-03-21T15:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to orient the text along the largest edge</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656788#M165236</link>
      <description>&lt;P&gt;In my opinion the longest edge must not be the right edge.&lt;/P&gt;&lt;P&gt;It is better to use semi-automatic rule, which allows you to pick the edge you want to align text to and use GeometricalConstraints to align text to this projected edge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeLinearFilter, "Pick the edge")
Dim edge As Edge = TryCast(pick, Edge)
If edge Is Nothing Then Return


Dim largestFace As Face = Nothing
Dim largestArea As Double = 0
For Each face As Face In edge.Faces
    'Skip non-planar faces
    If Not TypeOf (face.Geometry) Is Plane Then Continue For

    If face.Evaluator.Area &amp;gt; largestArea Then
        largestFace = face
        largestArea = face.Evaluator.Area
    End If
Next

'Return, when largest planar face wasn't found
If largestFace Is Nothing Then Return

Dim pointOnFace As Point = largestFace.PointOnFace

'Create sketch
Dim partDef As PartComponentDefinition = edge.Parent.ComponentDefinition
Dim sketch As PlanarSketch = partDef.Sketches.Add(largestFace)
Dim addByProjectingEntity As SketchEntity = sketch.AddByProjectingEntity(edge)
Dim textBox As Inventor.TextBox = sketch.TextBoxes.AddFitted(sketch.ModelToSketchSpace(pointOnFace), "&amp;lt;--&amp;gt;")
textBox.ShowBoundaries = True
sketch.GeometricConstraints.AddParallel(addByProjectingEntity, textBox.BoundaryGeometry(2))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 21 Mar 2024 16:25:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12656788#M165236</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-03-21T16:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to orient the text along the largest edge</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12657959#M165281</link>
      <description>&lt;P&gt;Thank you all for the proposed solutions!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 04:55:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-orient-the-text-along-the-largest-edge/m-p/12657959#M165281</guid>
      <dc:creator>ice_sid</dc:creator>
      <dc:date>2024-03-22T04:55:11Z</dc:date>
    </item>
  </channel>
</rss>

