08-31-2023
04:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-31-2023
04:04 PM
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