Hello, I'm trying to solve a problem Ive got with reattaching Leader Text, Balloons and Sketched Symbols with Leaders. If a part in a assembly is suppressed and then unsuppressed the Annotations fall off. I have created a rule to reattach all the Leader Text Annotations but a cant find the code to identify the if the leader text or the leader is unattached, if you look at the attached example for reattaching dimensions within the code.
' Add each un-attached dimension to the select set.
Dim oDrawDim As DrawingDimension
'iterate each dimension
For Each oDrawDim In oDrawDoc.ActiveSheet.DrawingDimensions
'if it is orphaned
If Not oDrawDim.Attached Then
' set the layer to the dummy layer
oSelectset.Select(oDrawDim)
The (.Attached) identifies if the dimension is attached or Un-attached
Public Class Drawing Private Com As New Common Private oApp As Inventor.Application Public Sub ReatachDimensions() MsgBox("ReatachDimensions Is Running") ' Get the active document, assuming it is a drawing. Dim oDrawDoc As DrawingDocument oDrawDoc = oApp.ActiveDocument MsgBox(oDrawDoc.DisplayName) ' Get the collection of dimensions on the active sheet. Dim oDimensions As DrawingDimensions oDimensions = oDrawDoc.ActiveSheet.DrawingDimensions ' Get a reference to the select set and clear it. Dim oSelectset As SelectSet oSelectset = oDrawDoc.SelectSet oSelectset.Clear() ' Add each un-attached dimension to the select set. Dim oDrawDim As DrawingDimension 'iterate each dimension For Each oDrawDim In oDrawDoc.ActiveSheet.DrawingDimensions 'if it is orphaned If Not oDrawDim.Attached Then ' set the layer to the dummy layer oSelectset.Select(oDrawDim) ' Get the CommandManager object. Dim oCommandMgr As CommandManager oCommandMgr = oApp.CommandManager ' Get control definition for the arrange dimensions command. Dim oControlDef As ControlDefinition oControlDef = oCommandMgr.ControlDefinitions.Item("DLxAnnoReconnectCmd") ' Execute the command. Call oControlDef.Execute() oSelectset.Clear() 'Call Run_CMD("DLxAutoReattachSickAnnotationsCmd") End If Next End Sub
And this is the code for Reattaching the Leader Text, as you can see it does'nt identify if any of the Leaders that are unattached. i suspect its got something to do with the Leaders for all the Leader Text, Balloons and Sketched Symbols. But i reallly need be able to differenciate between Attached and Un-attached.
Public Sub Reatachleader() MsgBox("Reatachleader Is Running") ' Get the active document, assuming it is a drawing. Dim oDrawDoc As DrawingDocument = oApp.ActiveDocument Dim oSheet As Sheet = oDrawDoc.ActiveSheet 'This Drawing Document Select Set Dim oSelectset As SelectSet = oDrawDoc.SelectSet oSelectset.Clear() Dim oLeaderNotes As LeaderNotes = oSheet.DrawingNotes.LeaderNotes For Each oLeaderNote As Inventor.LeaderNote In oLeaderNotes oSelectset.Select(oLeaderNote) '------------------- Do Somthing ------------------------ ' Get the CommandManager object. Dim oCommandMgr As CommandManager oCommandMgr = oApp.CommandManager ' Get control definition for the arrange dimensions command. Dim oControlDef As ControlDefinition oControlDef = oCommandMgr.ControlDefinitions.Item("DLxAutoReattachSickAnnotationsCmd") ' Execute the command. Call oControlDef.Execute() 'Call Run_CMD("DLxAnnoReconnectCmd") 'Call Run_CMD("DLxAutoReattachSickAnnotationsCmd") '------------------- End Doing Somthing ----------------- oSelectset.Clear() Next End Sub
I would appreciate any help i can get with this.
Thanks In advance.
Paul H
Hi Paul,
You could check the leader nodes:
Dim lt As LeaderNote Set lt = ThisApplication.ActiveDocument.SelectSet(1) Dim nodes As LeaderNodesEnumerator Set nodes = lt.Leader.AllNodes Call MsgBox(nodes(nodes.count).AttachedEntity Is Nothing)
Cheers,
I have a related problem that I've been dealing with maually for quite some time, and would like to make my job easier. I currently have a macro I wroote a few years back that adds a leadernote to a centermark on included points in a part in an assembly to place an indentifying tag for the point (with or without XYZ coordinates) on the drawing, and it works quite well. However, whenever I have to revise the assembly with a new part, and I derive the workpoints into the new part, I currently have to open the drawing with updates deferred, then manually drag all those leader connections away from the original points, then update the drawing, go through and include the new points and then re-attach the leadernotes manually. Otherwise, even though preserve annotations is turned on, those leadernotes just disappear entirely when opening the drawing without deferring updates (which has been an ongoing issue as long as I have used Inventor, going on 15 years!).
Since these leadernotes are kind of "sticky" to the centermark they are attached to (you have to drage the leader away far enough to break the connection), I'd like to be able to write a macro where I could just click on the leader and dis-associate it to the centermark without having to drag it. Any ideas?
TIA, Bob