3 Replies Latest reply on Mar 10, 2015 11:44 PM by Kasun Udayanga

    Get coordinates point in a sketch (Problem negativ/positiv value)

    Charles Robin

      Hi everyone



      I use this code to get the point coordinates where i just clicked with my mouse:

      Its working if i select a sketch point, and also if i click on 3D Model surface.


      Sub main()

      Dim swApp As SldWorks.SldWorks

      Dim Part As ModelDoc2

      Dim SelMgr As SldWorks.SelectionMgr


      Set swApp = Application.SldWorks

      Set Part = swApp.ActiveDoc

      Set SelMgr = Part.SelectionManager


      Dim point As Variant

      point = SelMgr.GetSelectionPoint2(1, -1)


      Debug.Print point(0) 'X

      Debug.Print point(1) 'Y

      Debug.Print point(2) 'Z


      End Sub





      I don't know why, sometime, when i'm editing a sketch, the coordinate axes can be reversed:



      As you can see in this example, the 'X' axe of the sketch is in a reverse sens of the 'X' axe of the 3D model.


      So if i click on a sketch point, i have the sketch coordinates.

      And if i click on the surface of the Model, i got the 3D model coordinate  ...:  the negative of the X sketch coordinates, even if its in the same location.


      Then if i want to insert a block in the sketch, by the way of clicking on the Model surface,

      the block will appear in the symetrie of 'Y' axe, because  X = - X.


      Can you have a solution to coordonate (haha) the landmark?


      Maybe a different code or a VBA trick?


      Thank you very much!