Change font size with VB.net

Change font size with VB.net

CAD_CAM_MAN
Advocate Advocate
2,874 Views
2 Replies
Message 1 of 3

Change font size with VB.net

CAD_CAM_MAN
Advocate
Advocate

I need to add a note to an active drawing (sheet 1) and change its fontsize with a VB application on button click. I have the following code...

 

Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click

Dim DRAW As DrawingDocument = _invApp.ActiveDocument

Dim DS1 As Sheet = DRAW.Sheets(1)

Dim TRG As Inventor.TransientGeometry = _invApp.TransientGeometry

Dim P1 As Point2d = TRG.CreatePoint2d(2, 3.5)

Dim MyNote As GeneralNote = DS1.DrawingNotes.GeneralNotes.AddFitted(P1, "TEST TEXT RESIZE") 

End Sub

 

I cannot seem to find the correct syntax to change the text fontsize in "MyNote" without changing it in the style with

MyNote.TextStyle.FontSize = 0.5 etc..

 

To clarify I do not want to change the fontsize in the style. I only want to change the fontsize in "MyNote"

 

If you double click on a note in a drawing it brings up the "Format Text" dialog box, in which the "Size" value is accessible. This size value is what I need to change for all the text in the note.

 

The application I am building is running with Inventor 2015.

I have to be making this harder than it is.

Anybody got a fix or appropriate syntax?

 

 

0 Likes
Accepted solutions (1)
2,875 Views
2 Replies
Replies (2)
Message 2 of 3

RodrigoEiras
Advocate
Advocate
Accepted solution

 

This works for FormattedText in a TextBox, so I guess it also works in a GeneralNote Object. This allows you to override the text format for a particular object, without affecting the style.

 

oTextBox.FormattedText = "<StyleOverride FontSize = '25'>" & "Some Text" & "<StyleOverride Color = '255,0,0'>" & _
"</StyleOverride>" & "</StyleOverride>"

 

If you just want to change the size the syntax would be something like this:

 

SyntaxEditor Code Snippet

oTextBox.FormattedText = "<StyleOverride FontSize = '" & dTextSize & "'>" & "TOP" & "</StyleOverride>"

 

I hope it helps!

 

 

Message 3 of 3

CAD_CAM_MAN
Advocate
Advocate
Thank you. That is what I was after!
0 Likes