Hallo @Anonymous
so änderst du dann noch Farbe und kannst den Text formatieren.
Ich habe das bei A3 ergänzt. Es scheint mir auch sinnvoller den ganzen Text vorher zu erstellen und dann in sText zu übergeben und nicht zwei einzelne Textfelder zu erzeugen, je nach Anwendungsfall.
Sub Wasserzeichen()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oActiveSheet As Sheet
Set oActiveSheet = oDrawDoc.ActiveSheet
Dim oGeneralNotes As GeneralNotes
Set oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
oDrawDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").item("Creation Time").Value = Date
Dim oC As Color
Set oC = ThisApplication.TransientObjects.CreateColor(120, 120, 120)
Call oC.SetColor(255, 0, 0)
Dim sText As String
sText = "Example" & vbCrLf & Date
Select Case oDrawDoc.ActiveSheet.Size
Case kA3DrawingSheetSize
Dim oGeneralNote As GeneralNote
Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(23.9, 4.9), sText)
oGeneralNote.Color = oC
oGeneralNote.FormattedText = "<StyleOverride FontSize = '1.5'>" & sText & "</StyleOverride>"
'sText = Date
'Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(24.4, 4.4), sText)
Case kA4DrawingSheetSize
Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(2.9, 4.9), sText)
sText = Date
Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3.4, 4.4), sText)
End Select
End Sub
Hier kam der entscheidende Hinweis her:
https://forums.autodesk.com/t5/inventor-customization/text-style-in-general-note/td-p/6255006
Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
