7 Replies Latest reply on Mar 18, 2017 5:19 PM by Lindsen Cruz

    Select note, not view

    Lindsen Cruz

      There is a note that is inside a drawing view. I would like to get the selected note but GetSelectedObjectType3 returns 12 which is a View, not a note.

       

      Is there any way to get the selected note inside a view, not the view itself, by other means?

        • Re: Select note, not view
          Raghvendra Bhargava

          Try this:

           

          Option Explicit

          Dim swApp As SldWorks.SldWorks

          Dim swDrawing As SldWorks.DrawingDoc

          Dim swDrView As SldWorks.View

          Dim annArray As Variant

          Dim obj As Variant

          Dim currAnn As SldWorks.Annotation

          Dim fileName As String

          Dim errors As Long

          Dim warnings As Long

          Sub main()

              Set swApp = Application.SldWorks

             

              Set swDrawing = swApp.ActiveDoc

              'Get drawing views and names of annotations in

              'each drawing view

              Set swDrView = swDrawing.GetFirstView

              'First drawing view is the sheet, so get first drawing view

              Set swDrView = swDrView.GetNextView

              While Not swDrView Is Nothing

                  Debug.Print "Name of drawing view: " & swDrView.GetName2

                  annArray = swDrView.GetAnnotations

                  If Not IsEmpty(annArray) Then

                      For Each obj In annArray

                          Set currAnn = obj

                          If currAnn.GetType = 6 Then '6=swNote

                              Debug.Print "  Name of annotation: " & currAnn.GetName

                              currAnn.Select3 True, Nothing

                          End If

                      Next obj

                  End If

                  Set swDrView = swDrView.GetNextView

              Wend

          End Sub

          • Re: Select note, not view
            Josh Brady

            Check GetSelectedObjectCount.  I believe you'll find that any time you're working in drawings and you select something, the first thing selected in SW is a view, and the second thing is the thing you actually selected.