12 Replies Latest reply on Nov 10, 2015 12:34 PM by Joel Foo

    Set Attachment Point

    Joel Foo

      Quick Question:

       

      Does Solidworks provide a way for me to set the attachment point of a note?

      I know I can get the attachment point position from IAnnotation->GetAttachPos().

       

      Joel

        • Re: Set Attachment Point
          Claudius Claudius

          Hello,Can you help me to get a solidworks2015 API document (not SDK,,it's the document which introduces the solidworks2015API) ,I will thank you very much.

          My email address is 1795112184@qq.com

          • Re: Set Attachment Point
            Amen Allah Jlili

            The INote interface has a method, GetAnnotation(), that returns an IAnnotation object which you can use to get the attachment point.

             

            Look at this example.

             

            Hope this helps!

              • Re: Set Attachment Point
                Joel Foo

                Hey Amen,

                 

                I need to SET the attachment point of the note. I know how to get the attachment point.

                 

                Thanks,

                Joel

                  • Re: Set Attachment Point
                    Amen Allah Jlili

                    Annotation.SetPosition doesn't do it for you?

                      • Re: Set Attachment Point
                        Joel Foo

                        Unfortunately not. IAnnotation->SetPosition only adjusts the position of the TEXT, it does not change the position of the leader arrow.

                         

                        If I have a Note pointing to an edge in a drawing, and I wish to change the position of the arrow to another point on the same edge- how do I do so? I cannot seem to find any methods in the Solidworks api that allows me to do so. 

                         

                        As another example, can I get a Note to point to some arbitrary point in a drawing?

                         

                        Thanks

                          • Re: Set Attachment Point
                            John Alexander

                            I looked for a way of doing this for a month back in the Spring (sw 2012). The only solution I came up with was to insert the note at the desired position for the leader arrow and then move the note to its final position. The leader will continue to point wherever it pointed upon insertion. The two biggest drawbacks to this method are that it is clunky and it doesn't attach the leader to components (even if the insertion point was dead on).

                             

                             

                            edit: This was for sketch block insertion but I think the principle is the same.

                              • Re: Set Attachment Point
                                Joel Foo

                                The current method I am using now is to attach notes to a selected edge in a drawing. When the note is created and attached - the attachment point defaults to the starting vertex of the edge. For example, if I'm attaching a note to a circle edge entity in a drawing, the default attachment point is the lower left of the circle.

                                 

                                Can I change this point to somewhere else on the edge?

                                 

                                Currently I'm going to try to create an arbitrary point at the position I want and have the note point to that, then delete the point.

                                  • Re: Set Attachment Point
                                    John Alexander

                                    Maybe there is a big difference between sketch block instance insertion and note insertion. The method for inserting sketch block instances takes a mathPoint as an argument for the position.

                                     

                                    It appears that you are using InsertNote(). From the documentation:

                                     

                                    "The leader attachment points for the new note come from the selections made before calling this method. The initial location of the note will be near the selection location."

                                     

                                    Are you selecting the desired edge programatically in VBA or pre-selecting it in the model? I think you might be able to get the results you want by changing the selection method. The method that you are using probably assigns the end-point of the line segment as a the 'selection location' but there might be an alternative way of selecting the edge that will also allow you to specify the selection location.

                                     

                                    This is just a hypothesis. One piece of information that might support it is the fact that when you pre-select an edge in the model before adding a note, you can manipulate the position of the leader based on the selection location (where you clicked when pre-selecting the edge).

                                      • Re: Set Attachment Point
                                        Joel Foo

                                        I am indeed using the IModelDoc->InsertNote() method to insert a note. My project is a C++ standalone which creates a drawing without any input from the user. Thus, there is no 'pick' point to which I can reference.

                                         

                                        My current route of investigation will be: 

                                         

                                        1. Create a new note at specified location on the drawing.

                                        2. Get the origin of this note

                                        3. Select an edge and use IEdge->GetClosestPointOn method to find the closest point of the note origin to that edge.

                                        4. Create a sketch point at that closest point.

                                        5. Attach the note to that sketch point

                                        6. Delete the sketch point.