7 Replies Latest reply on Apr 4, 2017 3:46 AM by Denis Messager

    API, attach a note to a drawing view

    Denis Messager

      Hi guys,

      I'm currently making a macro to allow users to make dimenions ballooning on drawings. I mean, the user is able to select a dimension on a drawing and the macro create a note with a balloon format and a specif number. Next, I would like to group the note made with the dimension selected, but it seems I need to attach the note to the view of the dimension before.

      I'm moving forward with my code, but I'm stopped because I can't find a way to get the drawing view of the selected dimension...
      Also, I don't understand the difference between the entities "dimension" and "displaydimension"  available in API.

       

      Please help me :-)

      Below the function where I'm stopped (I'm french, so excuse me for the comments and the variable names in french) :

       

          Private Function ms_MouseLBtnDownNotify(ByVal X As Long, ByVal Y As Long, ByVal WParam As Long) As Long

         

              'si pas création de balloon en cours

                  If PositionnementBalloonEnCours = False And ObjectEstPreSelectionné = True Then

                     

                      Set myNote = swModel.InsertNote(UserForm1.TextBoxNumero.value)

                      Set MyDimension = MonObjectPreSelectionné

       

                      If Not myNote Is Nothing Then

                         myNote.Angle = 0

                         boolstatus = myNote.SetBalloon(12, 0)

                         Set myAnnotation = myNote.GetAnnotation()

                         If Not myAnnotation Is Nothing Then

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

                          boolstatus = myAnnotation.SetPosition(X, Y, Z)

                         End If

                      End If

                 

                      UserForm1.TextBoxNumero.value = UserForm1.TextBoxNumero.value + 1

                 

                      PositionnementBalloonEnCours = True

                     

                'si création de balloon en cours

                  ElseIf PositionnementBalloonEnCours = True Then

                     

                      swModel.ClearSelection2 True

                     

                      'on attache le balloon à la vue (fonction attach to view)

                      bool = myAnnotation.Select3(True, swSelData)

                      bool = MyDimension.       'How to be able to select the dimension's drawing view before to attach the annotion to it ?

                     

                      bool = swModel.AttachAnnotation(swAttachAnnotationOption_View)

                     

                      'on attache le balloon à la dimension (fonction group)

                     

                     

                      PositionnementBalloonEnCours = False

                      Set myAnnotation = Nothing

                     

                  End If

                 

          End Function

        • Re: API, attach a note to a drawing view
          Josh Brady

          Setting the "FocusLocked"  property of the view to "True" will force anything you create to belong to the view you are focused on.

           

          Alternately, there are a lot of already available options for putting inspection balloons on dimensions.  Are you reinventing the wheel?  Some cost money, but what is the value of your time?  Or, here's just one (free) option:

           

          Macro not working in 2017

            • Re: API, attach a note to a drawing view
              Denis Messager

              Thanks Josh for your quick reply.

              Unfortunately, it seems the existing options and code don't fit my need. I'll would like to balloon whatever I want on the drawing (dimension, notes, geometric tolerance...).

               

              The code I've made so far let the user click on the item he want, it create a note with a balloon format and it moves along with the mouse. With a  second click, the code freeze the note position. This way the user can balloon each item he wants on the drawing.

               

              I don't know how to get the view of the object selected in the first time.

               

              I'm trying to not reinvent the wheel :-), so I've looked over this forum to find some code examples with what I need. without success so far...

               

              Thanks for your help.