8 Replies Latest reply on Oct 28, 2014 2:56 PM by Jacob Corder

    Find if note is attached to dimension

    Neil Sommerville

      I am adding inspection notes that are attached to dimensions on my drawing.  They are simply a number or letter, one or two charaters long with a boarder around it like a dimond or other shape.  They are vary similar to a balloon.    They are attached so that when I move the dimension the note moves along with it.

       

      I can find and loop each dimension or note in a drawing using ".GetFirstNote" or ".GetDisplayDimensions".    However I cannot find away to detemined if the note is attached to the dimension or vise versa.   Or at least I am not undertanding it.  I have looked at ".GetAttached" and ".GetLinked" but it is not getting me anywhere.

       

      Surely there is a way to determine if a dimension has a note attached to it, or if a note is attached to a dimension.

       

      Thanks for the help.

        • Re: Find if note is attached to dimension
          Artem Taturevych

          You can try this method: Annotation::GetAttachedEntities3. But as stated in the remarks you may run into a limitation. You should use INote::GetAnnotation or IDisplayDimension::GetAnnotation to get the IAnnotation from those interfaces.

          • Re: Find if note is attached to dimension
            Neil Sommerville

            I sent a request in to Solidworks and this the response.  

             

            "I can find the APIs CreateGroup, RemoveGroups, and RemoveItemsFromGroup, but I don’t see any interface at a higher level which enables you to query what’s in a group and to change or manage it. The way this is usually handled for features in SolidWorks is through “Feature data” interface objects, but there doesn’t exist such a thing for Annotation Groups.

             

            It looks like what you’re running into is the long-standing enhancement request, SPR 255800 (“Would like API for Annotation Group”), part of which states: “…would like an API to query and modify an Annotation Group…”. This has been requested by a few people previously; what I’ll do is reference it in this Service Request, to indicate that another request for this has been made.

             

            As for alternatives, the only one I can think of for now is to use Sketch Blocks, but that might be a more cumbersome mechanism than you need, or want to deal with."

             

            Bummer, but I appreciate the quick response from Solidworks API Support.

            • Re: Find if note is attached to dimension
              Jacob Corder

              you will need to cross Compare all Notes and Annotations in a view

               

              Annotation is the comon item here between DisplayDimensions and Notes.

               

              Dim ISwapp As SldWorks

              Dim ViewAnnotations as object = IView.GetAnnotations.

              Dim ViewNotes as Object = iview.GetNotes

               

              For Each ViewAnn as Annotation in ViewAnnotations

                  Select Case ViewAnn.GetType

                        Case SwAnnotationType_e.swDisplayDimension

                                For Each VNote as Note in ViewNotes

                                            Dim NoteAnn as annotation = vnote.GetAnnotation

                                          ' Use either

                                            If ISwapp.IsSame(ViewAnn,NoteAnn) = SwObjectEquality_e.SwObjectSame then

                                                'You Have Found the Annotation For This Note.

                                                  Dim ThisDim as displaydimension = noteAnn.GetSpecificAnnotation

                                                  'Here is Your DisplayDimension Object. To Get Dimension call .GetDimension2(0) 'if chamfer See Api.

                                            End if

                                            or

                                            if ViewAnn is NoteAnn then

                                                  'You Have Found the Annotation For This Note.

                                                  Dim ThisDim as displaydimension = noteAnn.GetSpecificAnnotation

                                                  'Here is Your DisplayDimension Object. To Get Dimension call .GetDimension2(0) 'if chamfer See Api.

                                            end if

                                  Loop

                  End Select

              Loop

              the code may not be 100% right. I just typed it in here. i have not tried it.