AnsweredAssumed Answered

How to convert MathPoint to sketch points

Question asked by Yong Ning on Jan 5, 2017

need result is x → 144.594524942555

but follow code result is -1.94494524942556

Helw me

Follow code, How to covert MathPoint  to sketch point ?

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

   Dim SwPt As MathPoint 

       Set SwPt = Ss(0)

MathPoint covert skech point ,resul is error

      Set SwPt2 = SwPt1.MultiplyTransform(SwSketch.ModelToSketchTransform)

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

 

MultiplyTransform1.jpg

 

''

Private Sub ll6()

   Dim swApp As SldWorks.SldWorks, swModel As ModelDoc2

       Set swApp = Application.SldWorks

       Set swModel = swApp.ActiveDoc

   Dim SwDraw As DrawingDoc

       Set SwDraw = swModel

   Dim SwView As View

       Set SwView = SwDraw.GetFirstView

       Set SwView = SwView.GetNextView

       SwDraw.ActivateView SwView.Name

   Dim oScale

       oScale = 1 / SwView.ScaleDecimal

   Dim SwViewXForm As MathTransform, vPos

       vPos = SwView.Position

   Dim SwSketch As Sketch

       Set SwSketch = swModel.GetActiveSketch

    

   'Dim SwViewXForm 'As ModelDoc2

       Set SwViewXForm = SwView.ModelToViewTransform

    

   Dim SwXForm As MathTransform

       Set SwXForm = SwSketch.ModelToSketchTransform

    

   Dim swSelMgr As SelectionMgr

       Set swSelMgr = swModel.SelectionManager

   Dim swDispDim As DisplayDimension, SwDim As Dimension

       Set swDispDim = swSelMgr.GetSelectedObject5(1)

       Set SwDim = swDispDim.GetDimension

   Dim SwAnn As Annotation

       Set SwAnn = swDispDim.GetAnnotation

       Ss = SwDim.ReferencePoints

    

 

       Set SwPt = SwPt.MultiplyTransform(SwView.ModelToViewTransform)

       Set SwPt1 = Ss(0) '

       Set SwPt2 = SwPt1.MultiplyTransform(SwSketch.ModelToSketchTransform)

    

    

   Dim x, y, Xx1, Yy1, Xx2, Yy2, tmp

   Dim xSel, ySel

       xSel = Pp(0) - SwDim.Value * SwView.ScaleDecimal / 2000

       ySel = Pp(1)

       ''

       x = Pp(0) - vPos(0)

       y = Pp(1) - vPos(1)

       x = x * oScale

       y = y * oScale

       ''

       Xx = SwPt.ArrayData(0) - vPos(0)

       Yy = SwPt.ArrayData(1) - vPos(1)

       Xx = Xx * oScale

       Yy = Yy * oScale

       ''

       Debug.Print Round(x * 1000, 3), Round(y * 1000, 3), Xx * 1000, Yy * 1000

       Debug.Print Round(x * 1000, 3), Round(y * 1000, 3), xSel * 1000, ySel * 1000

       Debug.Print SwPt1.ArrayData(0) - vPos(0), SwPt2.ArrayData(0)

       Stop

End Sub

Attachments

Outcomes