<?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: parameter driven text size for text field in sketch in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12666686#M11966</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;&amp;nbsp; ! Great support&amp;nbsp;!!&lt;/P&gt;&lt;P&gt;It took me a few trials to get this working to my liking…&lt;/P&gt;&lt;P&gt;I used the tool&amp;nbsp;&lt;A href="https://github.com/CSmichaelnavara/InventorVBA_ObjectBrowser" target="_blank"&gt;VBA Object Browser for Inventor&lt;/A&gt; &lt;SPAN&gt;you mentioned. But without any knowledge of VBA, I needed some time to understand all the steps. Worked perfectly for my needs. Thanks for sharing!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For the record, below a snippet of the code I ended using.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim odoc As PartDocument

odoc = ThisApplication.ActiveDocument
 
Dim osketch As Sketch

'The used sketch name in the extrusion is Text

osketch =odoc.ComponentDefinition.Sketches.Item("Sketch2")

'TextBoxes(1) is for text "e"
Dim textSize1 = Longueur * 0.125 / 10 ' mm -&amp;gt; cm (internal units)
Dim originalText1 = osketch.TextBoxes(1).Text

Dim formattedText1 = String.Format("&amp;lt;StyleOverride Font='Formata' FontSize='{0}'&amp;gt;{1}&amp;lt;/StyleOverride&amp;gt;", textSize1, originalText1)
osketch.TextBoxes.Item(1).FormattedText = formattedText1

'TextBoxes(2) is for text "so"
Dim textSize2 = Longueur * 0.127 / 10 ' mm -&amp;gt; cm (internal units)
Dim originalText2 = osketch.TextBoxes(2).Text

Dim formattedText2 = String.Format("&amp;lt;StyleOverride Font='Formata Regular' FontSize='{0}'&amp;gt;{1}&amp;lt;/StyleOverride&amp;gt;", textSize2, originalText2)
osketch.TextBoxes.Item(2).FormattedText = formattedText2

'and so on...

odoc.Update&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2024 14:55:54 GMT</pubDate>
    <dc:creator>jerome.darbellay</dc:creator>
    <dc:date>2024-03-26T14:55:54Z</dc:date>
    <item>
      <title>parameter driven text size for text field in sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12664130#M11962</link>
      <description>&lt;P&gt;Good day&lt;/P&gt;&lt;P&gt;I am looking for a solution to have the size (height) of various text fields in my sketch (which is a logo) automatically adjusted with a scale factor of my overall logo size.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example: my logo is 100mm long (variable “Length”, I would like to have the size of text field 1 to be 0.2*Length, size of text field 2 to be 0.35*Length, size of text field 3 to be 0.15*Length and so on…&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’ve searched the Inventor forum on this topic and reviewed the information in the topic “&lt;A href="https://forums.autodesk.com/t5/inventor-forum/having-text-size-based-on-another-parameter/m-p/8250579#M711263" target="_blank"&gt;Having text size based on another parameter&lt;/A&gt;”. I’ve tested the iLogic script proposed by&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4277453"&gt;@Lewis.Young&lt;/a&gt; in message 3. When I test this script, it will change the text value to “False” instead of changing the size (see screen capture). I have included my test file as an example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that I’ve no experience with iLogic nor VBA programming…&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 16:02:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12664130#M11962</guid>
      <dc:creator>jerome.darbellay</dc:creator>
      <dc:date>2024-03-25T16:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: parameter driven text size for text field in sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12665671#M11963</link>
      <description>&lt;P&gt;Avoid to construct too long lines with several assignments and conditions.&lt;/P&gt;&lt;P&gt;Here is modified version of your code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim odoc As PartDocument

odoc = ThisApplication.ActiveDocument
 
Dim osketch As Sketch

'The used sketch name in the extrusion is Text

osketch =odoc.ComponentDefinition.Sketches.Item("Sketch2")

Dim textSize = Longueur * 0.15 / 10 ' mm -&amp;gt; cm (internal units)
Dim originalText = osketch.TextBoxes(1).Text

Dim formattedText = String.Format("&amp;lt;StyleOverride FontSize='{0}'&amp;gt;{1}&amp;lt;/StyleOverride&amp;gt;", textSize, originalText)
osketch.TextBoxes.Item(1).FormattedText = formattedText
 
odoc.Update&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 07:27:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12665671#M11963</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-03-26T07:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: parameter driven text size for text field in sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12665719#M11964</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your answer!&lt;BR /&gt;This script works for the text size update, but also changes the text font (to Arial in my case), which is not desirable since I have specific font to use for my logo. How to retain the text font?&lt;/P&gt;&lt;P&gt;Another question: how do I know which index number (TextBoxes(1), TextBoxes.Item(1) / TextBoxes(2), TextBoxes.Item(2), so on) corresponds to which text field since I have more than 10 text fields to update? Is there a way to determine this without having to do iterative modification until I find the right index number of each text field?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 07:54:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12665719#M11964</guid>
      <dc:creator>jerome.darbellay</dc:creator>
      <dc:date>2024-03-26T07:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: parameter driven text size for text field in sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12665827#M11965</link>
      <description>&lt;P&gt;How to specify the font describes this &lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-915B75BA-4696-4fc7-A2C6-54B2BACDE7E1" target="_blank"&gt;article&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To the second question. You can browse the object tree using different tools. I use this&amp;nbsp;&lt;A href="https://github.com/CSmichaelnavara/InventorVBA_ObjectBrowser" rel="nofollow noopener noreferrer" target="_blank"&gt;VBA Object Browser for Inventor&lt;/A&gt;&lt;SPAN&gt;. Using this tool, you can easily select for example the sketch and look what is inside. Then you can get the indices of individual TextBoxes and use them in your code.&amp;nbsp;Another approaches, such as parsing the text field's "Text" property or labeling the text field with attributes, seem too complex for this purpose.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 09:03:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12665827#M11965</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-03-26T09:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: parameter driven text size for text field in sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12666686#M11966</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;&amp;nbsp; ! Great support&amp;nbsp;!!&lt;/P&gt;&lt;P&gt;It took me a few trials to get this working to my liking…&lt;/P&gt;&lt;P&gt;I used the tool&amp;nbsp;&lt;A href="https://github.com/CSmichaelnavara/InventorVBA_ObjectBrowser" target="_blank"&gt;VBA Object Browser for Inventor&lt;/A&gt; &lt;SPAN&gt;you mentioned. But without any knowledge of VBA, I needed some time to understand all the steps. Worked perfectly for my needs. Thanks for sharing!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For the record, below a snippet of the code I ended using.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim odoc As PartDocument

odoc = ThisApplication.ActiveDocument
 
Dim osketch As Sketch

'The used sketch name in the extrusion is Text

osketch =odoc.ComponentDefinition.Sketches.Item("Sketch2")

'TextBoxes(1) is for text "e"
Dim textSize1 = Longueur * 0.125 / 10 ' mm -&amp;gt; cm (internal units)
Dim originalText1 = osketch.TextBoxes(1).Text

Dim formattedText1 = String.Format("&amp;lt;StyleOverride Font='Formata' FontSize='{0}'&amp;gt;{1}&amp;lt;/StyleOverride&amp;gt;", textSize1, originalText1)
osketch.TextBoxes.Item(1).FormattedText = formattedText1

'TextBoxes(2) is for text "so"
Dim textSize2 = Longueur * 0.127 / 10 ' mm -&amp;gt; cm (internal units)
Dim originalText2 = osketch.TextBoxes(2).Text

Dim formattedText2 = String.Format("&amp;lt;StyleOverride Font='Formata Regular' FontSize='{0}'&amp;gt;{1}&amp;lt;/StyleOverride&amp;gt;", textSize2, originalText2)
osketch.TextBoxes.Item(2).FormattedText = formattedText2

'and so on...

odoc.Update&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 14:55:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12666686#M11966</guid>
      <dc:creator>jerome.darbellay</dc:creator>
      <dc:date>2024-03-26T14:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: parameter driven text size for text field in sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12800170#M11967</link>
      <description>&lt;P&gt;I like the idea of changing the fontsize of textboxes with a parameter. The only thing I miss is to do this on sketch or document base for all textboxes per sketch or document. I think per sketch is the easiest way, but the 1st Ilogic rule of &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;&amp;nbsp;only changed 1 textbox and not the other 200+ ones or more...&amp;nbsp; (it's a huge building site with that number of axis and there are drawings with manymore labels I want to do change fontsizes with parameters).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody help with in this 1st Ilogic rule with something If fontsize &amp;lt;&amp;gt; "Font_size_parameter1"; Change fontsize to&amp;nbsp;"Font_size_parameter1" EndIf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thnx in avance&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 14:50:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/parameter-driven-text-size-for-text-field-in-sketch/m-p/12800170#M11967</guid>
      <dc:creator>engineer_climeco</dc:creator>
      <dc:date>2024-05-27T14:50:23Z</dc:date>
    </item>
  </channel>
</rss>

