2 Replies Latest reply on Jun 10, 2014 1:55 AM by Shekhar Erande

    Attaching Note or Balloon to Part Edge not Drwaing?

    Shekhar Erande

      Hello Experts,


      I have application where I would like to show some sort of Text when user select edge on the PART NOT drawing . Is it possible in Solidworks? if yes please guide me.

      I dont want to use Drawing view.




        • Re: Attaching Note or Balloon to Part Edge not Drwaing?
          Santosh Pawar

          Hi Shekhar,


          You can use the NewSelectionNotify event handler to achieve this functionality, the vba code for this would look something like this,


          Private Function msrcPartDoc_NewSelectionNotify() As Long


             ' todo: Check the type of entity selected for type Edge and proceed

              Dim myNote As Object

              Dim myAnnotation As Object

              Dim myTextFormat As Object

              Set myNote = part.InsertNote("123")

              If Not myNote Is Nothing Then

                 myNote.LockPosition = False

                 myNote.Angle = 0

                 boolstatus = myNote.SetBalloon(0, 0)

                 Set myAnnotation = myNote.GetAnnotation()

                 If Not myAnnotation Is Nothing Then

                    longstatus = myAnnotation.SetLeader3(swLeaderStyle_e.swBENT, 0, True, False, False, False)

                    boolstatus = myAnnotation.SetPosition(0.621186585097226, 0.522873399967693, -0.641407457091692)

                    boolstatus = myAnnotation.SetTextFormat(0, True, myTextFormat)

                 End If

              End If

              part.ClearSelection2 True


          End Function

            • Re: Attaching Note or Balloon to Part Edge not Drwaing?
              Shekhar Erande

              Thanks santosh!! This exactly what I was looking for


              Here is my code for C# users


                object myTextFormat = "";

                          ModelDoc2 modelDoc2 = SWApp.IActiveDoc2;

                          myNote = modelDoc2.InsertNote("12345");



                          Note myNote1 = myNote as Note;



                          if (null != myNote1)


                              myNote1.LockPosition = false;

                              myNote1.Angle = 0;

                              bool boolstatus = myNote1.SetBalloon(0, 0);

                              IAnnotation myAnnotation = myNote1.GetAnnotation() as IAnnotation;



                              if (null != myAnnotation)



                                   int longstatus = myAnnotation.SetLeader3((int)swLeaderStyle_e.swSTRAIGHT, 0, true, false, false, false);

                                  boolstatus = myAnnotation.SetPosition(x, y, z);

                                  boolstatus = myAnnotation.SetTextFormat(0, true, myTextFormat);