1 Reply Latest reply on Jul 31, 2017 6:16 AM by Yong Ning

    SetArrowHeadStyleAtIndex→why don't change arrow style?

    Yong Ning

      In solidworks 2012 , API. Why don't change arrow head style?

      dot.jpg

       

       

      Private Sub del()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

             Set SwApp = Application.SldWorks

             Set SwModel = SwApp.ActiveDoc

         Dim SwSelMgr As SelectionMgr

             Set SwSelMgr = SwModel.SelectionManager

         Dim SwNote As Note, SwAnn As Annotation

             Set SwNote = SwSelMgr.GetSelectedObject5(1)

             Set SwAnn = SwNote.GetAnnotation

             With SwAnn

                 Debug.Print .GetArrowHeadStyleAtIndex(1)

                 .SetLeader3 swSTRAIGHT, 0, True, True, True, True

                 .SetArrowHeadStyleAtIndex -1, swNO_ARROWHEAD ' swDOT_ARROWHEAD

             End With

             Stop

      End Sub

       

      ***********************************************

       

      The return status of this method can have the following values:

          

      If value equals...

      Then the arrowhead style was...

      0

      Successfully set

      -1

      Not set because of an unknown error

      -2

      Not set because of an invalid index value

      -3

      Not set because of smart arrowhead styles being enabled

      -4

      Not set because of an invalid arrowhead style value

        • Re: SetArrowHeadStyleAtIndex→why don't change arrow style?
          Yong Ning

          Question, GetArrowHeadStyleAtIndex→Why don't is zero.

           

           

          if zero, can arrow style.

           

           

          *********************************************

          Private Sub del()

             Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                 Set SwApp = Application.SldWorks

                 Set SwModel = SwApp.ActiveDoc

             Dim SwSelMgr As SelectionMgr

                 Set SwSelMgr = SwModel.SelectionManager

             Dim SwNote As Note, SwAnn As Annotation

                 Set SwNote = SwSelMgr.GetSelectedObject5(1)

                 With SwNote

                      .SetBalloon 10, 0 ' swBF_Tightest

                      .SetName SwNote.GetText

                      Debug.Print .GetName

                 End With

                 ''

                 Set SwAnn = SwNote.GetAnnotation

                 With SwAnn

                     For ii1 = -2 To 2

                         .SetArrowHeadStyleAtIndex ii1, 1

                         Debug.Print ii1, .GetArrowHeadStyleAtIndex(ii1)

                     Next ii1

                 End With

                 Stop

          End Sub

           

          ''''''''''''''''''''''''

           

          Function DelSkPt(SwModel As ModelDoc2, SwSk As Sketch)

               Dim Ss

               Dim SkPt As SketchPoint

                   ''

                   If IsEmpty(SwSk.GetSketchPoints) Then

                       Exit Function

                   End If

                   For Each Ss In SwSk.GetSketchPoints

                       Set SkPt = Ss

                       SkPt.Select True

                   Next

                   SwModel.EditDelete

          End Function

          Function CreatePt(SwModel As ModelDoc2, SwView As View, Pt)

               Set CreatePt = SwModel.CreatePoint2( _

                    Pt(0) / SwView.ScaleDecimal, Pt(1) / SwView.ScaleDecimal, 0)

          End Function

          ''

          Private Sub del()

             Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                 Set SwApp = Application.SldWorks

                 Set SwModel = SwApp.ActiveDoc

             Dim SwMathUtil As MathUtility

                 Set SwMathUtil = SwApp.GetMathUtility

             Dim SwDraw As DrawingDoc

                 Set SwDraw = SwModel

             Dim SwView As View, SwNote As Note

                 Set SwView = SwDraw.GetFirstView

                 DelSkPt SwModel, SwView.GetSketch

                 Set SwView = SwView.GetNextView

                 'DelSkPt SwModel, SwView.GetSketch

                 '

             Dim vPt(2) As Double

             Dim SkPt1 As SketchPoint, SkPt2 As SketchPoint

             Dim AttPos, vPos

             Dim Ll, xDist, yDist

                 xDist = -10 / 1000

                 yDist = 5 / 1000

             Dim Anns, SwAnn As Annotation, Ss, Xx, Yy

                 Anns = SwView.GetAnnotations

                 ''

                 For ii = 0 To UBound(Anns)

                     Set SwAnn = Anns(ii)

                     Set SwNote = SwAnn.GetSpecificAnnotation

                     ''

                     If SwAnn.GetType = 6 And SwNote.IsBomBalloon Then

                        

                         AttPos = SwNote.GetAttachPos

                         'Set SkPt1 = SwModel.CreatePoint2(AttPos(0) / SwView.ScaleDecimal, AttPos(1) / SwView.ScaleDecimal, 0)

                         'vPos = SwAnn.GetPosition

                         ''

                         SwAnn.SetPosition AttPos(0) + xDist, AttPos(1) + yDist, 0

                         vPos = SwAnn.GetPosition

                         'Set SkPt2 = SwModel.CreatePoint2(vPos(0) / SwView.ScaleDecimal, vPos(1) / SwView.ScaleDecimal, 0)

                         Ll = Sqr((vPos(0) - AttPos(0)) ^ 2 + (vPos(1) - AttPos(1)) ^ 2)

                         Ll = Ll * 1000 / SwView.ScaleDecimal

                         Debug.Print Ll, SwNote.IsBomBalloon

                        

                        

                     End If

                     ''

                 Next ii

          End Sub