ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
DHDaen Hendrickson18/11/2020

I am using SW2019 SP5.

We are upgrading from SW2014 to SW2019 and part of that process involved recreating from scratch all of our templates. In the process of creating our drawing template a copy of a note got dropped randomly in the middle of the sheet and became dangling. It could not be selected to be deleted. Some reboots and rebuilds and it went away...

Or so I believed. It keeps showing up.

I ran this through my VAR and their answer was to just hide the layer it is on and/or check the document setting to Hide Dangling Dimensions and Annotations.

I don't like either of those approaches. Other items are on the layer that I do NOT want to hide. And if a dimension goes dangling I WANT to know about it.

I created a small vba to cycle through ALL annotations on the drawing hoping maybe the API could select the note. My API skills keep atrophying as I only get to dabble in it occasionally. Regardless, I was not successful in this approach either. I was successful in running some code. But unsuccessful in the code selecting the dangling note.

I am attaching the drawing template for your review in hopes someone has a method to make this annoyance go away.

I am really hoping to avoid remaking the template from scratch. In fact, three templates. Because I based two other drawing templates off this one and the dangling note persisted into them as well.

The attached image shows the dangling note - a copy of the other highlighted note. Both of these notes are on the "General Notes" layer. You can usually get the dangling note to appear by toggling the layer visibility. A ctrl-B rebuild will NOT make it vanish, but a ctrl-Q rebuild will.

Additionally, below is the rough code I was working with.

Thanks in advance,

Daen

Const DeleteLayer As String = "General Notes"

Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
'Dim swView As SldWorks.View
Dim swAnnNote As SldWorks.Note
Dim swAnn As SldWorks.Annotation
'Dim swSelMgr As SldWorks.SelectionMgr
'Dim swSelData As SldWorks.SelectData
Dim bRet As Boolean
'Dim i As Long

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Set swSelMgr = swModel.SelectionManager
'Set swSelData = swSelMgr.CreateSelectData

'If there is no document or the document is not a drawing then exit
If (swModel Is Nothing) Or (swModel.GetType <> swDocDRAWING) Then
Exit Sub
End If

Set swDraw = swModel
'Set swView = swDraw.GetFirstView
'Set swAnnNote = swView.GetFirstNote
Set swSheet = swDraw.GetCurrentSheet
Set swAnn = swSheet.GetTemplateSketch

' Clear the selection set for the sheet
swModel.ClearSelection2 True

Debug.Print "File = " & swModel.GetPathName

'Do While Not swView Is Nothing
Do While Not swAnn Is Nothing
If swAnn.Layer = DeleteLayer Then
bRet = swAnn.Select2(True, 0)
Debug.Print " " & swAnn.GetName
If swAnn.IsDangling Then
Debug.Print " Dangling!!!"
End If
End If
Set swAnn = swAnn.GetNext3
Loop
'Set swView = swView.GetNextView
'Loop

'Do While Not swNote Is Nothing
'Set swAnn = swNote.GetAnnotation
'If swAnn.Layer = DeleteLayer Then
'bRet = swAnn.Select2(True, 0)
'Debug.Print " " & swNote.GetName
'Debug.Print " "; swNote.GetText
'End If
'Set swNote = swNote.GetNext
'Loop

End Sub