how to create an textbox with an other font size ?

how to create an textbox with an other font size ?

Darkforce_the_ilogic_guy
Advisor Advisor
284 Views
1 Reply
Message 1 of 2

how to create an textbox with an other font size ?

Darkforce_the_ilogic_guy
Advisor
Advisor

I have to change font size how ?

 

I have this code.. I does what I want.. but the text is a lillte small. How do I get a other font size ? 

 

Public Sub Main()
    '  a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
     oDrawDoc = ThisApplication.ActiveDocument
    
    ' Create a new sketch on the active sheet.
    Dim oSketch As DrawingSketch
     oSketch = oDrawDoc.ActiveSheet.Sketches.Add
        Try
    oSketch.Name = "Welding Text" 
        
        Catch
               Exit Sub
        End Try
    ' Open the sketch for edit so the text boxes can be created.
    ' This is only required for drawing sketches, not part.
    oSketch.Edit
    
    Dim oTG As TransientGeometry
     oTG = ThisApplication.TransientGeometry
    
    ' Create text with simple string as input.  Since this doesn't use
    ' any text overrides, it will default to the active text style.
    Dim sText As String
    sText = "If notrhing is pecified, then welds must be" & vbCrLf & "made according to EN 1090-2:2018 EXC1"
    Dim oTextBox As TextBox

           
     oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(2, 2), sText)
    

    oSketch.ExitEdit
End Sub

' Function to calcuate the three points of a triangle that fits tightly around the input text box.
Private Sub CalculateTriangle(TextBox As TextBox, Points() As Point2d)
    ' Get the top-left corner of the text box.
    Dim dLeft As Double
    Dim dTop As Double
     GetCorner(TextBox, dLeft, dTop)
    
    Dim oTG As TransientGeometry
     oTG = ThisApplication.TransientGeometry
   
    ' Determine the top point of the triangle.
     Points(1) = oTG.CreatePoint2d(dLeft + (TextBox.Width / 2), dTop + ((TextBox.Width / 2) * Tan(1.0471975511966)))
    
    ' Determine the bottom-left corner point of the triangle.
    Dim dY As Double
    dY = (Points(1).Y - dTop) + (1.125 * TextBox.height)
     Points(2) = oTG.CreatePoint2d(Points(1).X - (dY / Tan(1.0471975511966)), Points(1).Y - dY)
    
    ' Determine the bottom right corner point of the triangle
     Points(3) = oTG.CreatePoint2d(Points(1).X + (dY / Tan(1.0471975511966)), Points(2).Y)
End Sub

' Function to determine the top left corner of the input text box.
Private Sub GetCorner(TextBox As TextBox, Left As Double, Top As Double)
    ' Determine the top left corner of the text box by accounting
    ' for the justifications.
    Select Case TextBox.HorizontalJustification
        Case kAlignTextLeft
            Left = TextBox.Origin.X
        Case kAlignTextCenter
            Left = TextBox.Origin.X - (TextBox.Width / 2)
        Case kAlignTextRight
            Left = TextBox.Origin.X - TextBox.Width
    End Select

    Select Case TextBox.VerticalJustification
        Case kAlignTextUpper
            Top = TextBox.Origin.Y
        Case kAlignTextMiddle
            Top = TextBox.Origin.Y + (TextBox.height / 2)
        Case kAlignTextLower
            Top = TextBox.Origin.Y + TextBox.height
    End Select
End Sub

 

0 Likes
285 Views
1 Reply
Reply (1)
Message 2 of 2

theo.bot
Collaborator
Collaborator

You can provide formatted text as input for the text box. You only defined a "simple" string. here is an sample how to override your format.:

The fontsize value is in database length unit (cm)

   Dim sText As String
    sText = "<StyleOverride Font='Segoe UI' FontSize='0,2' Bold='True'>If nothing is pecified, then welds must be</StyleOverride><Br/><StyleOverride Font='Segoe UI' FontSize='0,1'>made according To EN 1090-2:2018 EXC1</StyleOverride>"
	

 

theobot_0-1643695944858.png

 

0 Likes