@Anonymous wrote:
Try these scripts out in the API. Depending on whether or not you are using prompted entry for that text box you might want a different Script. I believe you're probably looking for the second of these two scripts though.
Uncomment the lines for the symbol's name if you want to isolate a specific symbol by name.
Good Luck!
Public Sub ChangeTextPromptOfSketchSymbolsOnAllSheets()
If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then Exit Sub
Dim oDrawDoc As DrawingDocument: Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oSymbol As SketchedSymbol
Dim strNewText As String: strNewText = InputBox("Enter New Text for Sketched Symbols.")
On Error Resume Next 'this allows the script to skip over the symbol if the first textbox is not a prompted entry textbox
For Each oSheet In oDrawDoc.Sheets
For Each oSymbol In oSheet.SketchedSymbols
' If oSymbol.Name = "STAMP" Then
Dim oText As TextBox
Set oText = oSymbol.Definition.Sketch.TextBoxes(1)
Call oSymbol.SetPromptResultText(oText, strNewText)
' End If
Next
Next
End Sub
Public Sub ChangeFirstTextBoxOfAllSketchedSymbolDefinitionsInDrawing()
If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then Exit Sub
Dim oDrawDoc As DrawingDocument: Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oSymbolDef As SketchedSymbolDefinition
Dim strNewText As String: strNewText = InputBox("Enter New Text for Sketched Symbols.")
'as written, this will disregard any prompted entry textboxes and reset them to static text
For Each oSymbolDef In oDrawDoc.SketchedSymbolDefinitions
' If oSymbolDef.Name = "STAMP" Then
Dim oDrawSketch As DrawingSketch
Set oDrawSketch = oSymbolDef.Sketch
Call oSymbolDef.Edit(oDrawSketch)
Dim oText As TextBox
Set oText = oDrawSketch.TextBoxes.Item(1)
oText.FormattedText = strNewText
Call oSymbolDef.ExitEdit(True)
' End If
Next
End Sub
Thanks for your reply! You are right I am looking for the second script but it is not working properly:(
I'm testing the script on small drawing and I have created some Leader Text symbols (in Annotate tab) on the drawing with certain text.
(I suppose object "Leader Text" relates to Sketched symbols, am I right?)
Then I run the script. It changes text to specified in the sketched symbols and formatting of the text is reset. But if I open symbol by standard editor I see the old text. You can try it yourself.
Any ideas?