Detecting Sick LeaderNotes

Detecting Sick LeaderNotes

Zach.Stauffer
Advocate Advocate
371 Views
8 Replies
Message 1 of 9

Detecting Sick LeaderNotes

Zach.Stauffer
Advocate
Advocate

Anyone have a way to reliably detect sick LeaderNotes on a drawing? I've tried multiple things but every node seems to come back unattached and there isn't an .Attached property on this object.

0 Likes
372 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor

Hi @Zach.Stauffer.  I don't recall having a rule like that, but I think I know the basics of how to do it.  Starting from the LeaderNote object, use the LeaderNote.Leader property to get the Leader object.  Then I think you should check the Leader.HasRootNode property, and I think it should be True if there is at least one segment to it.  Or, iterate the LeaderNode objects in its Leader.AllNodes property value, then each one of those has the LeaderNode.AttachedEntity property.  I believe that only one (the last one in the collection, I think) will have a anything as the value of that property, which will be the GeometryIntent object, which defines the connection between the LeaderNode and whatever view geometry it is supposed to be attached to.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 9

zstaufferG2YC9
Explorer
Explorer

Thanks for the comment Wesley, that is what I tried but it seems like AttachedEntity is always Nothing, even when the LeaderNote is not sick. I have tried only looking at the RootNode and at the LeafNodes, they all return Nothing for Attached Entity.

 

0 Likes
Message 4 of 9

J-Camper
Advisor
Advisor

If you just want to know if one exists, you can check the design doctor with a control definition.  Like This:

	Private Function CheckForOrphanedAnnotations(dDoc As DrawingDocument) As Boolean
		CheckForOrphanedAnnotations = False

		For Each sh As Sheet In dDoc.Sheets
			If sh.ExcludeFromPrinting Then Continue For
			Try
				sh.Activate()
			Catch
				Logger.Error(sh.Name & " failed to activate ""Sheet"" for Orphaned Annotations.")
				Continue For
			End Try

			Try
				If Not ThisApplication.CommandManager.ControlDefinitions.Item("AppDesignDoctorCmd").Enabled Then ThisApplication.CommandManager.ControlDefinitions.Item("AppUndoCmd").Execute() : Continue For
				CheckForOrphanedAnnotations = True
				'ThisApplication.CommandManager.ControlDefinitions.Item("AppUndoCmd").Execute()
			Catch
				Logger.Error(sh.Name & " failed to check ""Design Doctor"" for Orphaned Annotations.")
				Continue For
			End Try

			Exit For
		Next

		Return CheckForOrphanedAnnotations
	End Function

It won't tell you which one is sick, but I have used it in an export utility to alert the user to issues before allowing the PDF export to initiate.

0 Likes
Message 5 of 9

marcin_otręba
Advisor
Advisor

hi,

 

i think this wll work:

 

Dim draw As DrawingDocument = ThisApplication.ActiveDocument
Dim ld As LeaderNote
For Each ld In draw.ActiveSheet.DrawingNotes.LeaderNotes
Dim nodes As LeaderNodesEnumerator = ld.Leader.AllNodes
 Dim lastNode As LeaderNode = nodes.Item(nodes.Count)
 Dim ent As Object = lastNode.AttachedEntity
 If ent Is Nothing Then
MessageBox.Show("unatached leadernote   " & ld.Text, "Title")
End If
Next

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor

It seems like there may simply not be anything in the Inventor API yet for this specific situation.  LeaderNotes in drawings do not need to be attached to anything and can be created out in the middle of nowhere, or moved away from something they used to be attached to, without it seeming to cause any issues.  These ones that are placed without being attached to anything can also contain links to information like standard iProperties in the 'attached model' without it actually being attached to anything, and it does not show there being an issue/error with the LeaderNote.  It simply will not show any data where that information was supposed to be.  Seems like there is only an issue if they were attached to something, then the thing they were attached to somehow becoming unavailable, without anyone actually moving or un-attaching it on purpose, which seems to trigger some sort of 'internal' flag or property and alert us to the issue in the user interface.  Therefore, it is difficult (or impossible) to check if they are 'sick' from the API alone.  Sometimes Inventor's user interface includes more functionality/behavior than we can simulate though the API yet at that time.  There is a similar situation within 3D sketches and their coincident constraints when WorkPoints were originally involved.  The constraints all seem to be between lines/curves and SketchPoints that got automatically generated, and their 'Attached' status can be either way, without causing problems, but once one of the WorkPoints gets deleted, the user interface indicates that there is a problem, which seemingly cant be found through the API, like there is a hidden property/status that we don't have access to or something.  It would be helpful if there were a Property like 'HealthStatus' on these types of objects which would return something like the HealthStatusEnum type value.  That would make tasks like this more logical or easier to manage on our end.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 9

J-Camper
Advisor
Advisor

@WCrihfield,

Yeah, I ran into this issue when I was trying to check orphaned annotations a while ago.  I think the "flags" might only be visible by the Design Doctor, which I've never been able to find API for.  My only workaround was the code I posted above where I check the status of the Design Doctor Control definition to know if anything on a sheet is sick/orphaned.  It was enough for my case as I just wanted to prevent exporting while there were issues with the drawing, but it lacks visibility on what the issues are.

I would love to see design doctor API, or the HealthStatusEnum integration you mentioned.

Message 8 of 9

WCrihfield
Mentor
Mentor

On that note, this might make a good point for an article in the Inventor Ideas board.  If one does not already exist, one of you could create one there, and post a link to this conversation there, and post a link to that Idea article here in this conversation, to attract votes for it.  I would certainly vote for it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 9

BM_Ashraf
Advocate
Advocate

Hi

I have also encounterd this Issue recently and yeah, it's very difficult through the API to Compare between a sick Note and a Normal one.
It can be found only through the Attached Entity, but this is not always working. As sometimes a sick Note(Bend Notes for example) points to a wrong Drawing Curve. But somehow Inventor can define it and shows it in Design Doctor

 

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

0 Likes