1 Reply Latest reply on Nov 2, 2018 7:18 AM by Gertjan Van Dijk

    Getting the coordinates of a point using its name

    Ananth Balasubramanian

      Guys, I need help in getting the coordinates of a point and displaying it in a message box by using the name of the point entity. In this case "sketch 5" using  solidworks api.

      I've gone through 'getselectedpoint2(1,-1)' but did'n't really understand much.

      Can someone get me going on this..

       

      Thank You

        • Re: Getting the coordinates of a point using its name
          Gertjan Van Dijk

          First things first: "Sketch5" is not the point, it is a sketch that has a point in it.

          You want to get the point out of the sketch first with ISketch.GetUserPoints2(), which will give you an array with information on all holes in this sketch.

           

          in your case:

          double[] pointCoords(Sketch sketch)

          {

               object[] sketchPoints = sketch.GetUserPoints2();

               object[] thisPoint = sketchPoints[0];

               double[] coords = (double[])thisPoint[6];

               return coords;

          }