Question:
The user wants to pick a drawing view, and change the result string of prmpted entry text in all sketched symbols, with the view name as the prefix.
Solution:
The prmpted entry text is defined in SketchedSymbolDefinition. And the final SkecthedSymbol provides the method SetPromptResultText which can set the result string of the specific prmpted entry text. The code below asks the user to pick one drawing view, find the specific prmpted entry text, and change its result string. It assumes the SketchedSymbolDefinition is named “MySymbol”and the prmpted entry text is named “MY_PROMPT”in the SketchedSymbolDefinition.
Actually, this workflow also applies TitleBlock, Border etc.
Dim doc as DrawingDocument
doc = ThisApplication.ActiveDocument
Dim oObj As Object
oObj = ThisApplication.CommandManager.
Pick(SelectionFilterEnum.kDrawingViewFilter,"Select a view:")
If oObj Is Nothing Then
Else
Dim viewName As String = oObj.Name
Dim oNewResultText
oNewResultText = viewName + "other description"
Dim oPromptText As TextBox
‘ assume the name of sketched symbol definition is
‘ "MySymbol"
Dim oSSD As SketchedSymbolDefinition
oSSD = doc.SketchedSymbolDefinitions("MySymbol")
” search the prompt textbox in definition
Dim oEachText As TextBox
Dim I
For I = 1 To oSSD.Sketch.TextBoxes.Count
oEachText = oSSD.Sketch.TextBoxes(I)
If (oEachText.Text = "MY_PROMPT") Then
‘ found the prompt text we want to copy
oPromptText = oEachText
Exit For
End If
Next I
‘change the result text of the SketchedSymbol
Dim oSS As SketchedSymbol
For Each oSS In doc.ActiveSheet.SketchedSymbols
If oSS.Definition.Name = "MySymbol" Then
MsgBox(oNewResultText)
oSS.SetPromptResultText(oEachText,oNewResultText)
End If
Next
End If


Leave a Reply