Find if note is attached to dimension

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.

SolidworksApi macros
Answers 8
AT
AT 2014-01-06 Best Answer

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.

NS
NS 2014-01-07

Thanks for the input.   After looking at this closer I as mistaken on my terms.  The note is actually "grouped" with the dimension and not technically "attached".  So now I am looking for a way to see if a dimension is grouped with a note.

NS
NS 2014-01-08

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.

AT
AT 2014-01-08

The only possible workarounds I can see apart of blocks is the following:

You can temporarily move the annotation you are interesting in and check which annotations are also moved. In this case you will be able to identify the grouped ones. This workaround can be very time consuming depending on how many annotations you need to check but it may worth it.

NS
NS 2014-01-08

Now that is interesting.   That might be worth it looking into.  Thanks.

MO
MO 2014-05-14

Hi Artem,

I have exactly the same problem as Neil: I have a note (similar to a balloon) attached to a drawing dimension ... attached means grouped, since I haven't found a different way to link a note (or a sketch block) to a dimension so that you can move the dimension and the note (balloon) follows the dimension ...

Well now I would like to get the dimension linked to a specific (named) note ... you suggested to temporarily move the note and see which dimension moves together ... well ... how can I detect this (programmatically of course ... )?

Neil, did you find some other way/workaround??

thanks!

NS
NS 2014-05-14

No, I haven't found a good way or workaround.

JC
JC 2014-10-28

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.