<?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: Change specific Text format in the Title block in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-specific-text-format-in-the-title-block/m-p/12418434#M161010</link>
    <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5057326"&gt;@Alex.Shechter&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would caution the use of change and even more so if your a beginner. It really comes up with code that does not exist in the Inventor API. Instead stick with published sources such as the API Help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example this&amp;nbsp; loop right here will go no where because there is no such object as textformats and nothing even related inside the sketch object shown &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=DrawingSketch" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. Maybe it was intending to use text boxes.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;For Each TextFormat As TextFormat In titleBlockDef.Sketches.Item("Schriftfeld").TextFormats
   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I am not entirely sure what your intending to do by your description of the worklfow so maybe can you provide an image of your intended changes?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also changing items in a titleblock is not best practice as you would normally change the titleblock to a custom one and simply swap that.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2023 15:12:43 GMT</pubDate>
    <dc:creator>A.Acheson</dc:creator>
    <dc:date>2023-12-04T15:12:43Z</dc:date>
    <item>
      <title>Change specific Text format in the Title block</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-specific-text-format-in-the-title-block/m-p/12418201#M160999</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to automate inventor drawing for specific cases and I want to create a code that checks Titleblock textformat with weight. I want to be able to format the weight (how many digits after the comma, unite etc) or to promt the user for specific text.&lt;BR /&gt;This seams to be way more complicated than I thought so here is the code that i managed to put together with a lot of help from chatGPT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the error is in the fact that the code does not specify whitch textformat in the title block sketch should be worked on.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The question&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;How do I make the code to check for a specific text format in the sketch of the title block?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;' Get the active document.
Dim oDoc As Document = ThisApplication.ActiveDocument

' Update the physical properties and calculate the weight.
oDoc.Update2()
Dim weight As Double = oDoc.ComponentDefinition.MassProperties.Mass

' Get the title block definition.
Dim titleBlockDef As TitleBlockDefinition = oDoc.ActiveSheet.TitleBlock.Definition

' Loop through all the text formats in the "Schriftfeld" sketch.
For Each TextFormat As TextFormat In titleBlockDef.Sketches.Item("Schriftfeld").TextFormats
    ' Check if the text format contains the word "weight".
    If TextFormat.Text.Contains("weight") Then
        ' Delete the text and variable.
        TextFormat.Text = ""
        TextFormat.Variable = Nothing
    End If
Next

' Prompt the user for the weight.
Dim weightPrompt As String = InputBox("What weight should it have?", "Weight Prompt", weight.ToString())

' Add the new text format with the user's weight.
Dim newFormat As TextFormat = titleBlockDef.Sketches.Item("Schriftfeld").TextFormats.Add(weightPrompt, 0, 0)
newFormat.Field = Nothing&lt;/LI-CODE&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 13:46:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-specific-text-format-in-the-title-block/m-p/12418201#M160999</guid>
      <dc:creator>Alex.Shechter</dc:creator>
      <dc:date>2023-12-04T13:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Change specific Text format in the Title block</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-specific-text-format-in-the-title-block/m-p/12418434#M161010</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5057326"&gt;@Alex.Shechter&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would caution the use of change and even more so if your a beginner. It really comes up with code that does not exist in the Inventor API. Instead stick with published sources such as the API Help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example this&amp;nbsp; loop right here will go no where because there is no such object as textformats and nothing even related inside the sketch object shown &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=DrawingSketch" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. Maybe it was intending to use text boxes.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;For Each TextFormat As TextFormat In titleBlockDef.Sketches.Item("Schriftfeld").TextFormats
   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I am not entirely sure what your intending to do by your description of the worklfow so maybe can you provide an image of your intended changes?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also changing items in a titleblock is not best practice as you would normally change the titleblock to a custom one and simply swap that.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 15:12:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/change-specific-text-format-in-the-title-block/m-p/12418434#M161010</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2023-12-04T15:12:43Z</dc:date>
    </item>
  </channel>
</rss>

