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

OK. That definitely sounds doable.  But how about, since it has already been manually edited, and we are about to manually edit it again (in a way), why not preserve the existing text that someone manually added, so you know what it was, then add that suggested note to a new last line of the call-out.

This code will do that:

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oHoleNotes As HoleThreadNotes = oSheet.DrawingNotes.HoleThreadNotes
Dim oHN As HoleThreadNote
Dim oStr, oEndText, oOtherText, oNewEndText As String
Dim oEndPos As Integer
If oHoleNotes.Count > 0 Then
	For Each oHN In oHoleNotes
		oStr = oHN.FormattedHoleThreadNote
		oEndPos = InStr(StrReverse(oStr), ">")
		If oEndPos > 1 Then
			'the text you want to put at the end to 'Highlight' it
			Dim oHText As String = "THIS HAS BEEN MANUALLY TYPED"
			oHN.FormattedHoleThreadNote = oStr & "<Br/>" & oHText
		End If
	Next
End If

Or if you simply want to remove any/all text after the last ">" character, you could use this:

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oHoleNotes As HoleThreadNotes = oSheet.DrawingNotes.HoleThreadNotes
Dim oHN As HoleThreadNote
Dim oStr, oEndText, oOtherText, oNewEndText As String
Dim oEndPos As Integer
If oHoleNotes.Count > 0 Then
	For Each oHN In oHoleNotes
		oStr = oHN.FormattedHoleThreadNote
		If InStr(StrReverse(oStr), ">") > 1 Then
		oHN.FormattedHoleThreadNote = Left(oStr, InStrRev(oStr, ">"))
		End If
	Next
End If

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' :thumbs_up:.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)