<?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 Fit text to drawing dimensions. in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12195222#M156859</link>
    <description>&lt;P&gt;Hello, I have been working on making automatic dimensions in a .dwg document but I have not been able to center the text of the dimensions, since the occurrences can vary in size and add more, I do not know if you can help me to center the text so that it is always in the center regardless of the size of the occurrence.&lt;/P&gt;&lt;P&gt;Since if I try to give size to the text on some occasions it is put with another dimension or it is too small, I attach the code that I am working on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
       
        If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub

        Dim oDDoc As DrawingDocument = ThisDoc.Document 
        Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager 
        Dim oDimStyles As DimensionStylesEnumerator = oStMgr.DimensionStyles   
        Dim oDimStyle As DimensionStyle = oDimStyles.Item("Default (ANSI)") 

        oDimStyle.ArrowheadType = ArrowheadTypeEnum.kBlankArrowheadType   
        oDimStyle.ArrowheadSize = 0.2286
        oDimStyle.ArrowheadHeight = 0.08 

        oDimStyle.Extension = 0.4572 
        oDimStyle.Gap = 0.000 
        oDimStyle.Spacing = 0.000  

        Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 

        Dim oDStyle As DimensionStyle = oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle

        Dim sFontSize As String = oDStyle.TextStyle.FontSize

        Dim x As Double
        x = 0.25
        oDStyle.TextStyle.FontSize = x
    End Sub&lt;/LI-CODE&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="image.png" style="width: 714px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1257869i5D4E67D044DF7B29/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2023 22:31:11 GMT</pubDate>
    <dc:creator>kv5053545</dc:creator>
    <dc:date>2023-08-24T22:31:11Z</dc:date>
    <item>
      <title>Fit text to drawing dimensions.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12195222#M156859</link>
      <description>&lt;P&gt;Hello, I have been working on making automatic dimensions in a .dwg document but I have not been able to center the text of the dimensions, since the occurrences can vary in size and add more, I do not know if you can help me to center the text so that it is always in the center regardless of the size of the occurrence.&lt;/P&gt;&lt;P&gt;Since if I try to give size to the text on some occasions it is put with another dimension or it is too small, I attach the code that I am working on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
       
        If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub

        Dim oDDoc As DrawingDocument = ThisDoc.Document 
        Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager 
        Dim oDimStyles As DimensionStylesEnumerator = oStMgr.DimensionStyles   
        Dim oDimStyle As DimensionStyle = oDimStyles.Item("Default (ANSI)") 

        oDimStyle.ArrowheadType = ArrowheadTypeEnum.kBlankArrowheadType   
        oDimStyle.ArrowheadSize = 0.2286
        oDimStyle.ArrowheadHeight = 0.08 

        oDimStyle.Extension = 0.4572 
        oDimStyle.Gap = 0.000 
        oDimStyle.Spacing = 0.000  

        Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 

        Dim oDStyle As DimensionStyle = oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle

        Dim sFontSize As String = oDStyle.TextStyle.FontSize

        Dim x As Double
        x = 0.25
        oDStyle.TextStyle.FontSize = x
    End Sub&lt;/LI-CODE&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="image.png" style="width: 714px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1257869i5D4E67D044DF7B29/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 22:31:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12195222#M156859</guid>
      <dc:creator>kv5053545</dc:creator>
      <dc:date>2023-08-24T22:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Fit text to drawing dimensions.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12195743#M156861</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Give it a try as I mentioned, at this point it should go through all the dimensions and center their positions.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
       
        If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub

        Dim oDDoc As DrawingDocument = ThisDoc.Document 
        Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager 
        Dim oDimStyles As DimensionStylesEnumerator = oStMgr.DimensionStyles   
        Dim oDimStyle As DimensionStyle = oDimStyles.Item("Default (ANSI)") 

        oDimStyle.ArrowheadType = ArrowheadTypeEnum.kBlankArrowheadType   
        oDimStyle.ArrowheadSize = 0.2286
        oDimStyle.ArrowheadHeight = 0.08 

        oDimStyle.Extension = 0.4572 
        oDimStyle.Gap = 0.000 
        oDimStyle.Spacing = 0.000  

        Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 

        Dim oDStyle As DimensionStyle = oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle

        Dim sFontSize As String = oDStyle.TextStyle.FontSize

        Dim x As Double
        x = 0.25
        oDStyle.TextStyle.FontSize = x

        Dim oDimensions As DrawingDimensions
        oDimensions = oDDoc.ActiveSheet.DrawingDimensions

        Dim oDrawDim As DrawingDimension

        For Each oDrawDim In oDimensions
           If TypeOf oDrawDim Is LinearGeneralDimension
              Call oDrawDim.CenterText
           End If
        Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2023 05:11:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12195743#M156861</guid>
      <dc:creator>m_baczewski</dc:creator>
      <dc:date>2023-08-25T05:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Fit text to drawing dimensions.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12197255#M156894</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14139840"&gt;@m_baczewski&lt;/a&gt;&amp;nbsp;, I was trying the code you provided but, I keep getting the same thing that the dimensions are put to one side of the dimension in a way that I understand that is the size of the text but if I put it smaller to make a smaller assembly is not reached to read by the same thing that is very small, is there any way to make the text resize if it goes out so to speak of the range of the arrows?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kv5053545_0-1692986084319.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1258298iBF3CC76541ADCD2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kv5053545_0-1692986084319.png" alt="kv5053545_0-1692986084319.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2023 17:54:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12197255#M156894</guid>
      <dc:creator>kv5053545</dc:creator>
      <dc:date>2023-08-25T17:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Fit text to drawing dimensions.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12201000#M156929</link>
      <description>&lt;P&gt;&lt;SPAN&gt;You can move the dimension text to the left side, for example of the code looks like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingDocument&lt;/SPAN&gt;
&lt;SPAN&gt;oDoc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDimensions&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingDimensions&lt;/SPAN&gt;
&lt;SPAN&gt;oDimensions&lt;/SPAN&gt; = &lt;SPAN&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveSheet&lt;/SPAN&gt;.&lt;SPAN&gt;DrawingDimensions&lt;/SPAN&gt;

&lt;SPAN&gt;oDimension1&lt;/SPAN&gt; = &lt;SPAN&gt;oDimensions&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(12)
&lt;SPAN&gt;oDimension1&lt;/SPAN&gt;.&lt;SPAN&gt;Text&lt;/SPAN&gt;.&lt;SPAN&gt;Origin&lt;/SPAN&gt; = &lt;SPAN&gt;"Yours new position dimension as Point2d"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Try changing the size of the dimension arrows.&lt;/SPAN&gt;&lt;SPAN&gt;You can also consider creating a drawing that will be more legible.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 09:58:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12201000#M156929</guid>
      <dc:creator>m_baczewski</dc:creator>
      <dc:date>2023-08-28T09:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Fit text to drawing dimensions.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12210709#M157158</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14139840"&gt;@m_baczewski&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;In the end, I didn't get the text to fit automatically, I decided to let the user choose the text size (based on another post here in the forum).&lt;BR /&gt;This rule only changes the text size, and the rule you provided I used to leave the values from the default style editor.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;    Try
        Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
		'Get the active linear dimension style in the document
        Dim oDStyle As DimensionStyle = oDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle 
		'Get current font size of dimension style
        Dim sFontSize As String = oDStyle.TextStyle.FontSize 
        
		'Display an input dialog box for the user to enter the new font size.
        Dim oInput As String
        oInput = InputBox("Active Dimension style = " &amp;amp; oDStyle.Name &amp;amp; vbLf &amp;amp; vbLf &amp;amp; "Enter a new font size in mm.", "Text size", Format(sFontSize / 0.1, "#0.0"))
        
        ' Check if the input is an integer (no decimal point)
        If IsNumeric(oInput) AndAlso Not oInput.Contains(".") Then
            ' Append ".0" to the input
            oInput = oInput &amp;amp; ".0"
        End If
        
		'Update dimension style font size with user input
        oDStyle.TextStyle.FontSize = CDbl(oInput) * 0.1

		
    Catch
		
    End Try&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 31 Aug 2023 23:04:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12210709#M157158</guid>
      <dc:creator>kv5053545</dc:creator>
      <dc:date>2023-08-31T23:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fit text to drawing dimensions.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12824085#M168217</link>
      <description>&lt;P&gt;o que eu&amp;nbsp; preciso é o contrario, preciso que quando o espaço para o texto for muito pequeno o texto seja automaticamente movido para a direita ou para a esquerda da linha&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 21:31:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fit-text-to-drawing-dimensions/m-p/12824085#M168217</guid>
      <dc:creator>jaime75</dc:creator>
      <dc:date>2024-06-06T21:31:48Z</dc:date>
    </item>
  </channel>
</rss>

