Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
kv5053545
in reply to: m_baczewski

Hi @m_baczewski,

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).
This rule only changes the text size, and the rule you provided I used to leave the values from the default style editor.

    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 = " & oDStyle.Name & vbLf & vbLf & "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 & ".0"
        End If
        
		'Update dimension style font size with user input
        oDStyle.TextStyle.FontSize = CDbl(oInput) * 0.1

		
    Catch
		
    End Try