Hi guys. Just posting another similar code solution I came up with for getting/reading PromtedEntries from something like a TitleBlock or SketchedSymbol. It contains a custom Function that you can supply the TitleBlock or SketchedSymbol to, and if it contains any PromtedEntries then it will should return a Dictionary(Of String, String) type value. A Dictionary is a type of collection which can contain entries which each hold a 'Key' and a 'Value', similar to the Inventor.NameValueMap type object. Perfect for returning both the 'Prompt' text, and the current value of each prompt. Then it shows you how to iterate the entries in that Dictionary, and how to get Array type objects from the Dictionary. It is currently set-up to write the Prompt & Value pairs out to the iLogic Log window, and also show you the Array of Prompt strings, and the Array of Values in simple dialogs, just to confirm their functionality.
Sub Main
'allow user to manually select a SketchedSymbol that has been placed on a sheet somewhere
Dim oSS As SketchedSymbol = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingSketchedSymbolFilter, "Select a SketchedSymbol.")
If oSS Is Nothing Then Return
'run our custom Function to extract Prompts & Prompt Values from it as a Dictionary
Dim oDict As Dictionary(Of String, String) = GetPromptedEntries(oSS)
If oDict Is Nothing OrElse oDict.Count = 0 Then Return
'just showing how to iterate the Dictionary entries, and 'Log' the results to the iLogic Log window
For Each oEntry As KeyValuePair(Of String, String) In oDict
Logger.Info(vbCrLf & "Prompt = " & oEntry.Key & vbCrLf & "Value = " & oEntry.Value & vbCrLf)
Next 'oEntry
'just an example of how to get an Array from the Dictionary
Dim sPrompts() As String = oDict.Keys.ToArray
'and just showing the resulting list in a simple dialog
a = InputListBox("", sPrompts, "", "Prompts")
Dim sValues() As String = oDict.Values.ToArray
b = InputListBox("", sValues, "", "Values")
End Sub
Function GetPromptedEntries(oObj As Object) As Dictionary(Of String, String)
If oObj Is Nothing Then Return Nothing
Dim oTBs As Inventor.TextBoxes = Nothing
Try : oTBs = oObj.Definition.Sketch.TextBoxes : Catch : End Try
If oTBs Is Nothing OrElse oTBs.Count = 0 Then Return Nothing
Dim oDict As New Dictionary(Of String, String)
For Each oTB As Inventor.TextBox In oTBs
If oTB.FormattedText.Contains("</Prompt>") Then
Dim sPrompt As String = oTB.Text.Replace("<", "").Replace(">", "")
Dim sPromptResult As String = oObj.GetResultText(oTB)
If Not oDict.ContainsKey(sPrompt) Then oDict.Add(sPrompt, sPromptResult)
'Logger.Info(vbCrLf & "Prompt = " & sPrompt & vbCrLf & "Value = " & sPromptResult & vbCrLf)
End If
Next 'oTB
Return oDict
End Function
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)