Format Text (Style selection) in a idw drawing VB.NET

Format Text (Style selection) in a idw drawing VB.NET

Anonymous
Not applicable
1,022 Views
4 Replies
Message 1 of 5

Format Text (Style selection) in a idw drawing VB.NET

Anonymous
Not applicable

Hi to all, is there a way to select the Style listed in the Style box, when inserting some text in a idw drawing, using VB.Net?

 

I would like to add text (Notes and Title) at specific place in the drawing.

 

Any help will be appreciated, thank's!

0 Likes
Accepted solutions (1)
1,023 Views
4 Replies
Replies (4)
Message 2 of 5

Owner2229
Advisor
Advisor

Hi, here is an example of how to format your text in a new drawing note via VB.Net.

Red highlighted is to be changed.

 

Dim oDoc As Inventor.Document = InventorApplication.ActiveDocument

Dim stext As String
stext = "<StyleOverride Font='ARIAL' FontSize = '0.1524' >PRINTED: " & Now() & "<Br/>BY: " & InventorApplication.GeneralOptions.UserName & "</StyleOverride>"

' Set a reference to the GeneralNotes object
Dim oGeneralNotes As Inventor.GeneralNotes = oDoc.ActiveSheet.DrawingNotes.GeneralNotes
    
Dim oTG As Inventor.TransientGeometry = InventorApplication.TransientGeometry   
Dim oGeneralNote As Inventor.GeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(0.3, 1.5), stext)
' Set the color of the note Dim oColor As Inventor.Color = InventorApplication.TransientObjects.CreateColor(128, 128, 128)oGeneralNote.Color = oColor ' Set the rotation of the note in Radians (1.5 ~ 90°) oGeneralNote.Rotation = 1.5 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thank's Mike, I already tried this one.  What i am looking for, is to select from the Styles Editor Standard Text already estabish.

0 Likes
Message 4 of 5

smilinger
Advisor
Advisor
Accepted solution

You can just provide the style name when you add the text.

 

Dim oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(0.3, 1.5), stext, "Your Text Style Name")

0 Likes
Message 5 of 5

Anonymous
Not applicable

That's perfect for me!

 

Thank's smilinger

0 Likes