AnsweredAssumed Answered

GetAttachPos

Question asked by Yong Ning on Jul 28, 2017

SwNote.GetAttachPos → Create Point.

Follow code, create AttachPos point is error.

 

Attpos.jpg

 

 

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

       Set SwView = SwView.GetNextView

       '

   Dim SwXForm As MathTransform

       Set SwXForm = SwView.ModelToViewTransform

   Dim vPt(2) As Double

   Dim SkPt As SketchPoint

   Dim MathPt As MathPoint

   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

           Debug.Print SwNote.GetText, SwNote.GetName

           With SwNote

                If .HasBalloon Then

                     Ss = .GetBalloonInfo

                     Ss = .GetAttachPos

                    

                     vPt(0) = Ss(0)

                     vPt(1) = Ss(1)

                     Set MathPt = SwMathUtil.CreatePoint(vPt)

                     Set MathPt = MathPt.MultiplyTransform(SwXForm)

                     With MathPt

                          Xx = .ArrayData(0) / SwView.ScaleDecimal

                          Yy = .ArrayData(1) / SwView.ScaleDecimal

                     End With

                    

                     SwModel.CreatePoint2 Xx, Yy, 0

                     Stop

                     Stop

                End If

           End With

       Next ii

  

End Sub

Attachments

Outcomes