1 Reply Latest reply on Feb 18, 2017 8:12 PM by Yong Ning

    SKETCHPOINT → coordinate transformation

    Yong Ning

      Pt.jpg

       

       

       

       

      Private Sub del()

          Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

              Set SwApp = Application.SldWorks

              Set SwModel = SwApp.ActiveDoc

          Dim tmp, tmp1, tmp2

              With SwModel

                      tmp = .Extension.SelectByID2("", "VERTEX", 0.2300188309882, 0.1745324620915, -24494.59, False, 0, Nothing, 0)

                      tmp1 = .Extension.SelectByID2("Point23", "SKETCHPOINT", 0.2300188309882, 0.1745324620915, -24494.59, False, 0, Nothing, 0)

                      'tmp2 = .Extension.SelectByID2("Point23", "SKETCHPOINT", 2.999933332593, -0.776, 0, False, 0, Nothing, 0)

                      'Stop

                      SwModel.CreatePoint2 2.999933332593, -0.776, 0

                      tmp2 = .Extension.SelectByID2("Point23", "SKETCHPOINT", 2.999933332593, -0.776, 0, False, 0, Nothing, 0)

                      Stop

              End With

            

      End Sub

       

       

      Help me

      CreatePoint2 2.999933332593, -0.776, 0 → coordinate transformation → 0.2300188309882, 0.1745324620915,

        • Re: SKETCHPOINT → coordinate transformation
          Yong Ning

          Help me

           

          Use  ???

                    Set SwViewXForm = SwView.ModelToViewTransform

          Or Use ???

                      Set SwSketchXForm = SwSketch.ModelToSketchTransform

           

           

           

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

          Private Sub del()

              Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                  Set SwApp = Application.SldWorks

                  Set SwModel = SwApp.ActiveDoc

              Dim SwDraw As DrawingDoc

                  Set SwDraw = SwModel

              Dim tmp, tmp1, tmp2

              Dim SwMathUnt As MathUtility

                  Set SwMathUnt = SwApp.GetMathUtility

              Dim SwView As View, SwSketch As Sketch

              Dim SwViewXForm As MathTransform, vPos

              Dim SwSketchXForm As MathTransform

             

            

                 Set SwSketch = SwModel.GetActiveSketch

                

                

            

                 Set SwSketchXForm = SwSketch.ModelToSketchTransform

                

              Dim Xx, Yy

              Dim SwPt As SketchPoint

              Dim SwPt1 As MathPoint, SwPt2 As MathPoint, SwPt3 As MathPoint

                   

                  Set SwView = SwDraw.GetFirstView

                  Set SwView = SwView.GetNextView

                  ''

                  vPos = SwView.Position

                  Set SwViewXForm = SwView.ModelToViewTransform

                 

                  ''

                  With SwModel

                          Set SwPt = SwModel.CreatePoint2(2.999933332593, -0.776, 0)

                          Set SwPt1 = SwMathUnt.CreatePoint(SwPt)

                          Set SwPt2 = SwPt1.MultiplyTransform(SwViewXForm)

                          ''

                          With SwPt2

                              Xx = .ArrayData(0)

                              Yy = .ArrayData(1)

                          End With

                          tmp2 = .Extension.SelectByID2("", "SKETCHPOINT", Xx, Yy, 0, False, 0, Nothing, 0)

                          Set SwPt3 = SwPt1.MultiplyTransform(SwSketchXForm)

                          ''

                          With SwPt3

                              Xx = .ArrayData(0)

                              Yy = .ArrayData(1)

                          End With

                          tmp3 = .Extension.SelectByID2("", "SKETCHPOINT", Xx, Yy, 0, False, 0, Nothing, 0)

                         

                          Stop

                  End With

               

          End Sub