I have coded as bellow, but it's still change font of all textboxes
Dim oTG As TransientGeometry
Dim oSketch As DrawingSketch
Dim oTextBox As TextBox
Dim oDrawDoc As DrawingDocument
Dim oStyle As ObjectDefaultsStyle
oTG = m_inventorApplication.TransientGeometry
oDrawDoc = m_inventorApplication.ActiveDocument
oStyle = oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults
oSketch = oDrawDoc.ActiveSheet.Sketches.Add
oSketch.Edit()
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(1, 0.5), "test line 1", oStyle.SketchTextStyle)
oTextBox.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter
oTextBox.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextMiddle
oTextBox.Style.Font = "My font"
oSketch.ExitEdit()
Hi,
You missed the part of creating a new text style and the using that for the new text box.
Using oStyle.SketchTextStyle to create the text and then doing oTextBox.Style.Font = "My font" is the same as oStyle.SketchTextStyle.Font = "My font", so you'll change the font for everything that is using that specific style.
Cheers,
Hi,
You missed the part of creating a new text style and the using that for the new text box.
Using oStyle.SketchTextStyle to create the text and then doing oTextBox.Style.Font = "My font" is the same as oStyle.SketchTextStyle.Font = "My font", so you'll change the font for everything that is using that specific style.
I don't really understand what you mean.
Do you have some examples?
Thx in advance
Cordially
Michel
Hi, if you want the font set to this particular Textbox only, you may consider not to manipulate the style, rather edit the FormattedText Property of the Textbox
This would be something like
oTExtBox.FormattedText= "<StyleOverride Font='Arial'>My text</StyleOverride>"
You can append several Overrides. like
oTExtBox.FormattedText= "<StyleOverride Font='Arial'>My Arialtext</StyleOverride>, My StyleText, <StyleOverride Italic='True'>My italictext</StyleOverride>"
HTH,
Daniel