<?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 Control the color of text with i-Logic in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12807752#M167990</link>
    <description>&lt;P&gt;Good morning/evening,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a piece of text on a drawing with i-Logic.&amp;nbsp; I have functional code that lets me create the text, set the text height and even locate the text on the drawing where I want it to be, but I can't find how to update the color.&amp;nbsp; Here is my code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;oSheet&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;.&lt;SPAN&gt;Sheets&lt;/SPAN&gt;(1)
&lt;SPAN&gt;oGenNotes&lt;/SPAN&gt; = &lt;SPAN&gt;oSheet&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingNotes&lt;/SPAN&gt;.&lt;SPAN&gt;GeneralNotes&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oTG&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;
&lt;SPAN&gt;oTG&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;
&lt;SPAN&gt;Z1&lt;/SPAN&gt; = &lt;SPAN&gt;vbNewLine&lt;/SPAN&gt;

&lt;SPAN&gt;sText&lt;/SPAN&gt; = &lt;SPAN&gt;"JUST"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;Z1&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"AN"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;Z1&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"EXAMPLE"&lt;/SPAN&gt;
&lt;SPAN&gt;sFormattedText&lt;/SPAN&gt; = &lt;SPAN&gt;"&amp;lt;StyleOverride FontSize = '4'&amp;gt;"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;sText&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"&amp;lt;/StyleOverride&amp;gt;"&lt;/SPAN&gt;
&lt;SPAN&gt;oGenNotes&lt;/SPAN&gt;.&lt;SPAN&gt;AddFitted&lt;/SPAN&gt;(&lt;SPAN&gt;oTG&lt;/SPAN&gt;.&lt;SPAN&gt;CreatePoint2d&lt;/SPAN&gt;(25, 30), &lt;SPAN&gt;sFormattedText&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2024 15:01:55 GMT</pubDate>
    <dc:creator>Guthery1</dc:creator>
    <dc:date>2024-05-30T15:01:55Z</dc:date>
    <item>
      <title>Control the color of text with i-Logic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12807752#M167990</link>
      <description>&lt;P&gt;Good morning/evening,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a piece of text on a drawing with i-Logic.&amp;nbsp; I have functional code that lets me create the text, set the text height and even locate the text on the drawing where I want it to be, but I can't find how to update the color.&amp;nbsp; Here is my code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;oSheet&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;.&lt;SPAN&gt;Sheets&lt;/SPAN&gt;(1)
&lt;SPAN&gt;oGenNotes&lt;/SPAN&gt; = &lt;SPAN&gt;oSheet&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingNotes&lt;/SPAN&gt;.&lt;SPAN&gt;GeneralNotes&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oTG&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;
&lt;SPAN&gt;oTG&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;
&lt;SPAN&gt;Z1&lt;/SPAN&gt; = &lt;SPAN&gt;vbNewLine&lt;/SPAN&gt;

&lt;SPAN&gt;sText&lt;/SPAN&gt; = &lt;SPAN&gt;"JUST"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;Z1&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"AN"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;Z1&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"EXAMPLE"&lt;/SPAN&gt;
&lt;SPAN&gt;sFormattedText&lt;/SPAN&gt; = &lt;SPAN&gt;"&amp;lt;StyleOverride FontSize = '4'&amp;gt;"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;sText&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"&amp;lt;/StyleOverride&amp;gt;"&lt;/SPAN&gt;
&lt;SPAN&gt;oGenNotes&lt;/SPAN&gt;.&lt;SPAN&gt;AddFitted&lt;/SPAN&gt;(&lt;SPAN&gt;oTG&lt;/SPAN&gt;.&lt;SPAN&gt;CreatePoint2d&lt;/SPAN&gt;(25, 30), &lt;SPAN&gt;sFormattedText&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 15:01:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12807752#M167990</guid>
      <dc:creator>Guthery1</dc:creator>
      <dc:date>2024-05-30T15:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Control the color of text with i-Logic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12807969#M167993</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2292024"&gt;@Guthery1&lt;/a&gt;.&amp;nbsp; First of all, there is no way to specify color of text within the 'FormattedText' portion of the code.&amp;nbsp; We can modify Font, Font Size, Bold, Italic, Underline, &amp;amp; Strikethrough with FormattedText though.&amp;nbsp; Second, you have not declared a variable to capture the new &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-GeneralNote" target="_blank" rel="noopener"&gt;GeneralNote&lt;/A&gt; object that your code is creating with the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GeneralNotes_AddFitted" target="_blank" rel="noopener"&gt;GeneralNotes.AddFitted&lt;/A&gt; method.&amp;nbsp; If you had declared a variable for holding a GeneralNote, then set the value of that variable with that GeneralNotes.AddFitted method, then you could have modified the color of the text after it was created, using its&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GeneralNote_Color" target="_blank" rel="noopener"&gt;GeneralNote.Color&lt;/A&gt;&amp;nbsp;property.&amp;nbsp; And, the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-Color" target="_blank" rel="noopener"&gt;Color&lt;/A&gt; object is a 'transient' object (just used for temporarily transferring organized data), so you can create a new one from the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-TransientObjects" target="_blank" rel="noopener"&gt;TransientObjects&lt;/A&gt;&amp;nbsp;object, using its &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=TransientObjects_CreateColor" target="_blank" rel="noopener"&gt;TransientObjects.CreateColor&lt;/A&gt;&amp;nbsp;method.&amp;nbsp; You can find the TransientObjects right under the main application (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Application_TransientObjects" target="_blank" rel="noopener"&gt;Application.TransientObjects&lt;/A&gt;&amp;nbsp;).&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 16:30:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12807969#M167993</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-05-30T16:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Control the color of text with i-Logic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12820000#M168127</link>
      <description>&lt;P&gt;I'm going to need to try this out. I haven't used the GeneralNote functions because I didn't need too.&amp;nbsp; The original code is a bit old and needs to be updated for increased functionality.&amp;nbsp; Unfortunately, you never know what you need it to do until you need it to do something new.&amp;nbsp; I'll get back to this later this week.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 11:58:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12820000#M168127</guid>
      <dc:creator>Guthery1</dc:creator>
      <dc:date>2024-06-05T11:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Control the color of text with i-Logic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12820190#M168131</link>
      <description>&lt;P&gt;OK.&amp;nbsp; Here is a couple of code examples you can play around with in the mean time that may help.&lt;/P&gt;
&lt;P&gt;This example creates a new GeneralNote on the active sheet of the active drawing, then changes its color to red.&amp;nbsp; It also shows how you can use the XML tag "&amp;lt;Br/&amp;gt;" for a line break within the text.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
If oDDoc Is Nothing Then
	MsgBox("iLogic rule '" &amp;amp; iLogicVb.RuleName &amp;amp; "' was aborted - no DrawingDocument found.", vbCritical, "iLogic")
	Return
End If
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oGNotes As Inventor.GeneralNotes = oSheet.DrawingNotes.GeneralNotes
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oNewGNote As Inventor.GeneralNote = Nothing
Dim oPoint As Point2d = oTG.CreatePoint2d(4, 5)
Dim sFText As String = "Some&amp;lt;Br/&amp;gt;Example&amp;lt;Br/&amp;gt;Text"
oNewGNote = oGNotes.AddFitted(oPoint, sFText)
oNewGNote.Color = oTO.CreateColor(255, 0, 0) 'red&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;This example allows you to either manually pre-select or pick (when the rule runs) an existing note in your drawing, then writes its FormattedText to the iLogic Log window for you, so you can review how it is currently formatted.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oPickedNote As DrawingNote = Nothing
Dim oSS As Inventor.SelectSet = ThisDoc.Document.SelectSet
If oSS.Count &amp;gt; 0 AndAlso (TypeOf oSS.Item(1) Is DrawingNote) Then
	oPickedNote = oSS.Item(1)
Else
	oPickedNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "Pick a drawing note.")
End If
If oPickedNote Is Nothing Then Return
Logger.Info(vbCrLf &amp;amp; oPickedNote.FormattedText)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 13:02:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/control-the-color-of-text-with-i-logic/m-p/12820190#M168131</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-06-05T13:02:11Z</dc:date>
    </item>
  </channel>
</rss>

