AnsweredAssumed Answered

ModelToViewTransform+MultiplyTransform

Question asked by Yong Ning on Jan 3, 2017
Latest reply on Jan 4, 2017 by Yong Ning

MultiplyTransform + ModelToViewTransform,

result is error .

 

MultiplyTransform.jpg

 

 

''

Private Sub ll3()

   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

   Dim SwViewXForm

       Set SwViewXForm = SwView.ModelToViewTransform

   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

   

   Dim SwPt As SketchPoint, Pp

   Dim SwPt1 As MathPoint, SwPt2 As MathPoint

       Pp = SwAnn.GetPosition

       Set SwPt1 = Ss(1)

       Set SwPt1 = SwPt1.MultiplyTransform(SwViewXForm)

       Set SwPt2 = Ss(2)

       Set SwPt2 = SwPt2.MultiplyTransform(SwViewXForm)

   

   

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

       ''

       Xx = Pp(0)

       Yy = Pp(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

       Stop

End Sub

Attachments

Outcomes