Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi @Chris.Truelove 

You are right... We are actually changing the actual style that the textbox is using. So every other textbox using this style will be updated aswell... I guess we'll have to create a new style. Try this :slightly_smiling_face:

 

Sub Main' SketchTextAdd()
' 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 Inventor.Sketch
oSketch = oDrawDoc.ActiveSheet.Sketches.Add

' Open the sketch for edit so the text boxes can be created.
' This is only required for drawing sketches, not part.
oSketch.Edit


'Identify border type
Dim oBorder = ActiveSheet.Border

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 = InputBox("Enter new Title Text", "Secondary Title ", "")
iProperties.Value("Custom", "Second Title " & ActiveSheet.Name) = sText

Dim oStyle As TextStyle = oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.SketchTextStyle

Dim oTextBox As Inventor.TextBox
If oBorder = "A3" Then
oTextBox = oSketch.TextBoxes.AddByRectangle(oTG.CreatePoint2d(22.7, 3.2), oTG.CreatePoint2d(35, 2.4), sText, oStyle)
Else If oBorder = "A4" Then
oTextBox = oSketch.TextBoxes.AddByRectangle(oTG.CreatePoint2d(10.39, 3.2), oTG.CreatePoint2d(22, 2.4), sText, oStyle)
Else If oBorder = "A4_P" Then
Dim A4_P_Style As TextStyle
Try
A4_P_Style = oDrawDoc.StylesManager.TextStyles.Item("A4_P_Style")
Catch
A4_P_Style = oStyle.Copy("A4_P_Style")
A4_P_Style.Font = "Arial"
A4_P_Style.FontSize = 1
End Try

oTextBox = oSketch.TextBoxes.AddByRectangle(oTG.CreatePoint2d(11.15, 6.195), oTG.CreatePoint2d(20.25, 4), sText, A4_P_Style)

End If
oSketch.ExitEdit

End Sub