4 Replies Latest reply on Aug 21, 2018 9:07 AM by Shital Thigale

    GetLeaderPointsAtIndex Method (IAnnotation)

    Shital Thigale

      how to find arrowhead coordinate?

          • Re: GetLeaderPointsAtIndex Method (IAnnotation)
            Shital Thigale

            Thank you  Nilesh  but this link is use full for part document and i am working on drawing document but it's not help full for finding arrow head coordinate or not mention how to detect position of arrow head

            Actually i have all ready find  all annotation in drawing document  but unable to find coordinate of individual annotation  because i need to create bounding box for arrowhead

            i was used :    ThisAnn = DisplayDimension.GetAnnotation();

                                         double[] pt =ThisAnn.GetPosition();

                                          x = pt[0];

                                         y =  pt[1];

                                        z=  pt[2];

            but its not sufficient for detecting arrow head coordinate or position

              • Re: GetLeaderPointsAtIndex Method (IAnnotation)
                Nilesh Patel

                Have a look at the attached macro:

                 

                Option Explicit
                
                
                Sub main()
                
                
                    Dim swApp          As SldWorks.SldWorks
                    Dim swModel        As ModelDoc2
                    Dim swSelMgr        As SelectionMgr
                    Dim swSelData      As SelectData
                    Dim swDraw          As DrawingDoc
                    Dim swView          As View
                    Dim swAnn          As Annotation
                    Dim vLeaderPt      As Variant
                    Dim nbrLeaders      As Long
                    Dim nNumPts        As Integer
                    Dim i              As Integer
                    Dim j              As Integer
                    Dim k              As Integer
                
                
                    Set swApp = Application.SldWorks
                    Set swModel = swApp.ActiveDoc
                    Set swSelMgr = swModel.SelectionManager
                    Set swSelData = swSelMgr.CreateSelectData
                    Set swDraw = swModel
                   
                    Set swView = swDraw.GetFirstView
                    Do While Not Nothing Is swView
                        Set swAnn = swView.GetFirstAnnotation3
                        Do While Not swAnn Is Nothing
                
                
                            Debug.Print "  Annotation name: " & swAnn.GetName
                            Debug.Print "  Annotation type (enumerator numeric value): " & swAnn.GetType
                           
                            If True = swAnn.GetLeader Then
                
                
                                nbrLeaders = swAnn.GetLeaderCount
                                For i = 0 To swAnn.GetLeaderCount - 1
                                    If True = swAnn.GetBentLeader Then
                                        nNumPts = 3
                                    Else
                                        nNumPts = 2
                                    End If
                                    swAnn.Select3 False, swSelData
                                   
                                    vLeaderPt = swAnn.GetLeaderPointsAtIndex(i)
                                    If Not IsEmpty(vLeaderPt) Then
                                        Dim leaderPt() As Double
                                        ReDim leaderPt(nNumPts) As Double
                                        leaderPt = vLeaderPt
                                        k = 0
                                        For j = 0 To UBound(leaderPt)
                                            Debug.Print "    Pt[" & k & "] x,y,z coordinates:"
                                            Debug.Print "      " & Str(leaderPt(j) * 1000) & ", " & Str(leaderPt(j + 1) * 1000) & Str(leaderPt(j + 2) * 1000)
                                            j = j + 2
                                            k = k + 1
                                        Next j
                                    End If
                                Next i
                            End If
                
                
                            Set swAnn = swAnn.GetNext3
                        Loop
                        Set swView = swView.GetNextView
                    Loop
                End Sub