Hi @hieut1392. You were right about the selection filter. It does not make sense to me though, because in the Inventor API Object Model, the ChamferNote object is found directly under DrawingNotes, so that should include anything under it. This time I added a real chamfer to a part, then added a real ChamferNote to that feature on the drawing, so I had something to test my code on. The FormattedChamferNote property returned a really long, and complicated String, full of lots of XML code, and lots of tolerance specs, even though there were no tolerances shown on the drawing. When I tried adding "3 x " text to the beginning of that, it resulted in some really odd-looking results, so I moved on to testing out the regular FormattedText property. That one was much simpler looking inside (only contained "<ChamferNote/>"), and when I did the same thing to that one, it worked just as expected. I modified my code a bit to include the InputBox routine I mentioned, just so you can see what I saw, but you can totally get rid of that bit of code afterwards, and just add the text to the start of that FormattedText, similar to what it is doing now, but without the help of the InputBox part.
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
'Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
AddQtyToChanferNote("3 x ")
End Sub
Sub AddQtyToChanferNote(oQty As String) 'Sub, because not returning anything
Repeat :
oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDefaultFilter, "Select a Chanfer Note.")
If IsNothing(oObj) OrElse (TypeOf oObj Is ChamferNote = False) Then Exit Sub 'Return Nothing
Dim oCNote As ChamferNote = oObj
Dim oFText As String = InputBox("Edit FText", "FormattedText", oCNote.FormattedText)
Try : oCNote.FormattedText = oFText : Catch : End Try
'Try : oCNote.FormattedText = oQty & oFText : Catch : End Try
GoTo Repeat
End Sub
Be careful copying though, I noticed in your VBA version of this code, that you are using the plural Type (ChamferNotes) when declaring your variable, instead of the singular Type (ChamferNote), which won't work. By the way, I highly recommend that you focus more of your Inventor automation focus on developing solutions with either iLogic or vb.net (iLogic uses vb.net as its basis), instead of VBA, because VBA has security problems, which is why Autodesk has stopped including the VBA Editor in any new installations of Inventor starting with 2021 version (Link).
Wesley Crihfield

(Not an Autodesk Employee)