Hi @ragul_ravi_ext. Trying to replicate the capabilities of that incredibly dynamic and powerful user interface 'Format Text' dialog can be very complicated, and sometimes may even not be possible, depending on what you may be trying to do. The functionality of the bottom row of controls in that dialog, just above the text box, is also pretty complex, and is used to specify which type of source collection to pull the data from, then which document to access that collection within, then which piece of information, then what precision of that data should be displayed. All those specifications get written into the 'FormattedText' Property of whatever type of object you happen to be editing at that time. We usually never see the contents of that Property, but only see the contents of that objects 'Text' Property, instead. You can read a bit more about the FormattedText at the following Inventor online help Link.
XML Tags for FormattedText
As you can see from the label of the Link, it involves what are known as 'XML Tags'. XML is a different, but very common programming language, used primarily for storing and reading data in a highly structured and organized way. The quickest way to learn what is needed in your specific situation, is to create the note manually, the way you want it...then 'inspect' it by code afterwards, where the code accesses its FormattedText Property's contents. Sort of like the idea of reverse engineering.
Below is an example iLogic rule that you can use to inspect the drawing note after you create it. The drawing should be Inventor's 'active' document when you run the rule. Then it will ask you to manually 'Pick' the drawing note. Then it will write the contents of its FormattedText to the iLogic Log window, but only if you already have that tab visible in Inventor's user interface before running the rule. Then it will prompt you with a small dialog, where the contents of its FormattedText will be in a editable text box, allowing you to copy it and/or edit its contents. If you edit its contents, it will then set that edited value back to the drawing note. So, if you edited it in the wrong way, it may throw an error.
Dim oDNote As Inventor.DrawingNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingNoteFilter, "Select a drawing note to inspect.")
If (oDNote Is Nothing) Then Return
Logger.Info(vbCrLf & oDNote.FormattedText)
Dim sFText As String = InputBox("Here is the LeaderNote.FormattedText:", "LeaderNote.FormattedText", oDNote.FormattedText)
oDNote.FormattedText = sFText
After running this, you can either copy the contents from that small dialog, or copy the text from the iLogic Log window, so that you can put that into your iLogic rule for setting a drawing note to Link to that property.
Below is another example, but it is very basic, and may need to be customized quite a bit to suit your specific needs. Right now, it just gets the 'active' drawing, then the active sheet in that drawing, then the first view on that sheet. Gets the model document being directly referenced by that view. Gets the first drawing curve within that view, as what geometry to 'attach' the pointer of the LeaderNote to. Then defines a 2D point just off the upper-left corner of the view for where to place the text of the note. Then puts those leader points in a collection. Then tries to gather the required information needed for specifying which property you want the note to be 'Linked' to. Then defines the contents of the FormattedText we want the leader note to use. Then creates the LeaderNote. No guarantees it will work perfectly on first run without any customization though, because there are a lot of potential places for it to fail.
Sub Main
Dim oInvApp As Inventor.Application = ThisApplication
Dim oDDoc As Inventor.DrawingDocument = TryCast(oInvApp.ActiveDocument, Inventor.DrawingDocument)
If oDDoc Is Nothing Then
MsgBox("A Drawing must be 'active' for this rule to work!", vbCritical, "Wrong Document Type")
Return
End If
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oDView As Inventor.DrawingView = oSheet.DrawingViews.Item(1)
'get the model document being detailed within this drawing's views
Dim oModelDoc As Inventor.Document = Nothing
Try
oModelDoc = oDView.ReferencedDocumentDescriptor.ReferencedDocument
Catch
End Try
If oModelDoc Is Nothing Then
MsgBox("No Model Document Found In First View On Active Sheet!", , "")
Return
End If
Dim oDCurve As Inventor.DrawingCurve = oDView.DrawingCurves.Item(1)
'this defines the 'connection' between a piece of geometry an an annotation
Dim oGIntent As Inventor.GeometryIntent = oSheet.CreateGeometryIntent(oDCurve)
'specify where the text of the leader should be (2 units outside top left corner of view)
Dim oTxtPt As Inventor.Point2d = oInvApp.TransientGeometry.CreatePoint2d()
oTxtPt.X = oDView.Left - 2
oTxtPt.Y = oDView.Top + 2
'put collection of leader node locations into a collection
Dim oLPts As Inventor.ObjectCollection = oInvApp.TransientObjects.CreateObjectCollection()
oLPts.Add(oGIntent)
oLPts.Add(oTxtPt)
Dim oLNotes As Inventor.LeaderNotes = oSheet.DrawingNotes.LeaderNotes
'in order to specify which iProperty we want the note to be pointing to,
'we need to be able to specify the 'internal name' of the PropertySet containing that Property
'in your case, that will be the 'custom' PropertySet, which is always the fourth set
Dim oCustomPropSet As Inventor.PropertySet = oModelDoc.PropertySets.Item(4)
Dim sPropSetID As String = oCustomPropSet.InternalName
'now try to get the custom Property
Dim oCustomProp As Inventor.Property = Nothing
Try
oCustomProp = oCustomPropSet.Item("TAGG")
Catch
End Try
If oCustomProp Is Nothing Then
MsgBox("No custom Property named 'TAGG' found in model document!", , "")
Return
End If
'get the ID of the custom Property, if it was found
Dim sPropID As String = oCustomProp.PropId.ToString()
'now define the FormattedText contents, incorporating those two pieces of information
Dim sFText As String = "<Property Document='model' FormatID='" & sPropSetID & "' PropertyID='" & sPropID & "' />"
'now create the LeaderNote, and specify that FormattedText
Dim oLNote As Inventor.LeaderNote = oLNotes.Add(oLPts, sFText)
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)