3 Replies Latest reply on Jun 20, 2014 11:01 AM by Klaudiusz Skiba

    Select a note by its name

    Klaudiusz Skiba

      Hello,

      I'm trying to select notes based on their names. I'm using swModel.Extension.SelectByID2(noteName, "NOTE" , 0, 0, 0,  False, 0, Nothing, 0).

      if I don't put coordinates in it won't pick it up.


        • Re: Select a note by its name
          Simon Turner

          Alternatively, use ModelDoc2.GetFirstAnnotation2 and Annotation.GetNext3 to loop through all annotations until you find the one with the correct name.

            • Re: Select a note by its name
              Klaudiusz Skiba

              Thank you for opening my blind sleepy eyes. So simple.

               

              *Edit.

              Sadly it doesn't work. Solidworks api states:

               

              For parts and assemblies, this method returns the first IAnnotation object in the model. For drawings, access the annotations using the IView::GetFirstAnnotation3 method.

               

              So I'm back to square one. Thanks again anyway.

                • Re: Select a note by its name
                  Klaudiusz Skiba

                  it is actually picked up by view beacuse sheet is considered a view. both codes work but note is faster

                   

                      While Not (swView Is Nothing)

                          Set swNote = swView.GetFirstNote

                          While Not (swNote Is Nothing)

                              noteName2 = swNote.GetName

                              Debug.Print "8888888*********" & noteName2

                              Set swNote = swNote.GetNext

                          Wend

                          Set swView = swView.GetNextView

                      Wend

                     

                    

                      Set swView = swDraw.GetFirstView

                     

                     

                      While Not (swView Is Nothing)

                          Set swAnno = swView.GetFirstAnnotation2()

                          While Not (swAnno Is Nothing)

                              noteName2 = swAnno.GetName

                              Debug.Print "9999999*********" & noteName2

                              Set swAnno = swAnno.GetNext

                          Wend

                          Set swView = swView.GetNextView

                      Wend