AnsweredAssumed Answered

SwDim.ReferencePoints+MathPoint

Question asked by Yong Ning on Jan 2, 2017
Latest reply on Aug 6, 2017 by Yong Ning

Follow code, result is Error.

 

Help me .

How to use MathPoint and ReferencePoints?

 

ReferencePoints2.jpg

 

ReferencePoints1.jpg

 

 

 

 

Private Sub ll()

   Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

       Set SwApp = Application.SldWorks

       Set SwModel = SwApp.ActiveDoc

   Dim SwDraw As DrawingDoc

       Set SwDraw = SwModel

   Dim SwSelMgr As SelectionMgr

       Set SwSelMgr = SwModel.SelectionManager

   Dim SwDispDim As DisplayDimension, SwDim As Dimension

       Set SwDispDim = SwSelMgr.GetSelectedObject5(1)

       Set SwDim = SwDispDim.GetDimension

       ss = SwDim.ReferencePoints

   Dim SwPt As MathPoint, SwPt1 As MathPoint, SwPt2 As MathPoint

       Set SwPt = ss(0)

       Set SwPt1 = ss(1)

       Set SwPt2 = ss(2)

   Dim Xx, Yy, Xx1, Yy1, Xx2, Yy2

       ''

       Xx = SwPt.ArrayData(0)

       Yy = SwPt.ArrayData(1)

       ''

       Xx1 = SwPt1.ArrayData(0)

       Yy1 = SwPt1.ArrayData(1)

       ''

       Xx2 = SwPt2.ArrayData(0)

       Yy2 = SwPt2.ArrayData(1)

       Debug.Print Xx * 1000, Yy * 1000

       Debug.Print Xx1 * 1000, Yy1 * 1000

       Debug.Print Xx2 * 1000, Yy2 * 1000

       SwModel.CreateLine2 Xx1, Yy1, 0, Xx2, Yy2, 0

       SwModel.CreateLine2 Xx, Yy, 0, Xx2, Yy2, 0

       SwModel.CreateLine2 Xx1, Yy1, 0, Xx, Yy, 0

End Sub

Outcomes