LEADER NOTE FILTER SETTINGS

LEADER NOTE FILTER SETTINGS

ragul_ravi_ext
Participant Participant
98 Views
4 Replies
Message 1 of 5

LEADER NOTE FILTER SETTINGS

ragul_ravi_ext
Participant
Participant

HI

I try to access the leader note settings via i logics i cannot be able to achieve can anyone help me on this i need to select the type, source must default and parameter and need to add parameter in leader via i logic code.

ragul_ravi_ext_0-1756365933216.png

 

0 Likes
Accepted solutions (1)
99 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor
Accepted solution

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

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

ragul_ravi_ext
Participant
Participant

Thank for the code but how to access the instant property any tips 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

I am not sure what yo mean by 'instant property'.  If you mean the value of the property that the note is pointing to, after it has been 'retrieved' from the model, then no, I am not sure how to get that directly from that note by code.  If the note is pointing to an iProperty, and we know which one it is, and in which document, then there are other ways of retrieving the value of an iProperty, without going through the note object though.  Those note objects do not have a direct property containing the 'retrieved value' from some other source...just the definition of what information to retrieve, and where to get it from.  And they do not have a direct method for retrieving the value from its source either.  The DrawingNote object, and the LeaderNote object (which is a Type derived from the DrawingNote Type), both have similar properties.   The LeaderNote.Text property's value is what you see in the 'Format Text' dialog, so when it is just pointing to a custom iProperty, it usually just contains a label for the linked data within the < & > symbols, not the actual resulting/retrieved value.  And we have already covered what we will see in the LeaderNote.FormattedText Property value.  If the note's text did not contain any 'Links' to other external information, then its 'Text' property would contain exactly what was specified (static text).  If the note were just for a 'Prompted Entry', instead of 'pointing to' some other external data, then there is sometimes a way to retrieve its resulting value...but even then its resulting value is not a direct property of that object.  Some other hidden functionality of Inventor must be retrieving the value from the source then displaying it on the drawing sheet.  I agree that this seems like a shortcoming, or missing functionality in Inventor's API.  The capabilities exposed to us Inventor users through Inventor's API seems to get expanded a bit each year, and sometimes existing functionality gets improved a bit too.  We sometimes like to think that we can do anything by code, that we can do manually...but that simply is not then case...at least not yet.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

I just created an 'Idea' post in the Inventor Ideas forum about this seemingly missing functionality.  I have wanted this ability myself for a while, and have heard others asking for it for years also.  I will post the Link to that Idea post below, so that others who find this forum topic, can find that Idea, and hopefully 'Vote' for it.  Voting for Idea posts is similar to clicking the Like button, and increases their popularity.  If an idea gets enough attention, and seems possible for the folks at Autodesk to implement, it may start getting investigated and may even get implemented in an upcoming version of Inventor.

https://forums.autodesk.com/t5/inventor-ideas/add-getresulttext-method-in-inventor-api-for-drawingno... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes