Re-Attach Annotation

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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