Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi @martin.jerabekM5BZE.  Here is an iLogic rule example for finding & replacing text within either the Title, or the Cells of a CustomTable in a DrawingDocument.  It is currently set up to loop through each sheet, and each CustomTable it finds on each sheet.  Then after checking/processing its title, it will loop through each Row, and each Cell in each Row, checking/processing them.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
		MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
		Exit Sub
	End If
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oSheets As Inventor.Sheets = oDDoc.Sheets
	Dim sTextToFind As String = "ToFind"
	Dim sTextToReplaceIt As String = "Replacement"
	For Each oSheet As Inventor.Sheet In oSheets
		Dim oCTables As Inventor.CustomTables = oSheet.CustomTables
		If oCTables.Count = 0 Then Continue For 'skip to next oSheet in loop
		For Each oCTable As Inventor.CustomTable In oCTables
			If oCTable.Title.Contains(sTextToFind) Then
				Try
					oCTable.Title = oCTable.Title.Replace(sTextToFind, sTextToReplaceIt)
				Catch
					Logger.Error("Error replacing text in Title of CustomTable")
				End Try
			End If
			'<<< you can traverse the data in the table by rows or by columns >>>
			Dim oRows As Inventor.Rows = oCTable.Rows
			For Each oRow As Inventor.Row In oRows
				For Each oCell As Inventor.Cell In oRow
					If oCell.Value.Contains(sTextToFind) Then
						Try
							oCell.Value = oCell.Value.Replace(sTextToFind, sTextToReplaceIt)
						Catch
							Logger.Error("Error replacing text in Cell of CustomTable")
						End Try
					End If
				Next 'oCell
			Next 'oRow
		Next 'oCTable
	Next 'oSheet
	If oDDoc.RequiresUpdate Then oDDoc.Update2(True)
	'If oDDoc.Dirty Then oDDoc.Save2(False)
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) :thumbs_up:.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)