Hi @elena_dragomirDX7D9. Thanks for including the edited pictures for more information to go by this time. There are multiple types of things in drawings that can have what you are calling 'field text', such as Borders, TitleBlocks, SketchedSymbols, and other stuff. We would also normally need to know the 'prompts' for each field you are looking for, because they can be pretty difficult to find otherwise, since we literally have to search through individual TextBox objects within the definition sketch of something to find them. But in this case, since you just want them all, and do not seem to care what order they are processed in, it is not as much of a challenge. I have developed multiple code processes specifically for identifying and interacting which what are known as 'Prompted Entries' from those types of drawing entities. Below is an example of some code you can copy & paste into an empty iLogic rule, and run it while one of those types of drawings is the 'active' document in Inventor. It will first make sure the current document is a drawing, then get that...but if it is a part or assembly, it will not do anything. Next it tries to get the TitleBlock from the 'active' Sheet in the drawing. If there is not one, which is possible, then it will not do anything. Next, it looks within the definition sketch of that TitleBlock and gets its collection of TextBoxes, then starts iterating through them, looking for specific formatting which indicates they are for a 'Prompted Entry', not any thing else. When it finds one, it gets both its 'Prompt' text, and the value of that prompt, if any, and writes those into Dictionary entries (collection of two factor pairs of data). If something was found & returned from that process, another process then attempts to either update, or create custom iProperties, with the prompt text as the name of the Property, and the prompt value as the Property's value. I did not include any 'comments' or 'feedback' in the code for now, but could if needed.
Sub Main
Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
If oDDoc Is Nothing Then Return
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oTBlock As Inventor.TitleBlock = oSheet.TitleBlock
If oTBlock Is Nothing Then Return
Dim oPromptedEntriesDict As Dictionary(Of String, String) = GetPromptedEntries(oTBlock)
DictionaryToCustomProperties(oDDoc, oPromptedEntriesDict)
End Sub
'works for Borders, TitleBlocks, & SketchedSymbols
Function GetPromptedEntries(oObj As Object) As Dictionary(Of String, String)
If oObj Is Nothing Then Return Nothing
Dim oTBoxes As Inventor.TextBoxes = Nothing
Try : oTBoxes = oObj.Definition.Sketch.TextBoxes : Catch : End Try
If (oTBoxes Is Nothing) OrElse (oTBoxes.Count = 0) Then Return Nothing
Dim oDict As Dictionary(Of String, String) = New Dictionary(Of String, String)
For i As Integer = 1 To oTBoxes.Count
Dim oTBox As Inventor.TextBox = oTBoxes.Item(i)
If oTBox.FormattedText.Contains("</Prompt>") Then
Dim sPrompt As String = oTBox.Text.Trim("<", ">")
Dim sPromptResult As String = oObj.GetResultText(oTBox)
If Not oDict.ContainsKey(sPrompt) Then oDict.Add(sPrompt, sPromptResult)
'Logger.Info(vbCrLf & "Prompt = " & sPrompt & vbCrLf & "Value = " & sPromptResult & vbCrLf)
End If
Next 'oTBox
Return oDict
End Function
Sub DictionaryToCustomProperties(doc As Inventor.Document, _
dict As Dictionary(Of String, String))
If (dict Is Nothing) OrElse (dict.Count = 0) Then Return
Dim oCProps As Inventor.PropertySet = doc.PropertySets.Item(4)
For Each oEntry As KeyValuePair(Of String, String) In dict
Dim oCProp As Inventor.Property = Nothing
Try : oCProp = oCProps.Item(oEntry.Key) : Catch : End Try
If oCProp IsNot Nothing Then
Try : oCProp.Value = oEntry.Value : Catch : End Try
Continue For
End If
Try : oCProp = oCProps.Add(oEntry.Value, oEntry.Key) : Catch : End Try
Next 'oEntry
End Sub
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)