I have a 2D sketch on a plane. The plane is not coincident with the front plane. The plane is parallel to the front plane. I am using the code below to get coordinates from the points in the plane. Two questions:

- When I use the code below I get a value for a point as

x: 2.5234

y: 1.2154

z: 0

Z is always zero even though the plane is at 0.050 meters from the front plane. I expect the Z to return 0.05. Solidworks is obviously doing some kind of 2D math and then transforming the 2D sketch into 3D space to get the x/y/z coordinate? How do I get the actual 3D coordinate rather than a 2D coordinate? - I am only after the points. When I say points I mean the sketch entity that is called a point. I currently get the center of a circle as well. How would I filter a sketch point?

Code:

ISketch sketch = (ISketch)feature.GetSpecificFeature2();

object[] points = (object[])sketch.GetSketchPoints2();

foreach (ISketchPoint point in points)

{

Point3D pt = new Point3D(point.X, point.Y, point.Z); //<--Point.Z is always zero.

result.Add(pt);

}

You need to use the sketch transform matrix to get the model point. See ModelToSketchTransform Property of ISketch. Artem has some info on transforms here: Using transformations in SOLIDWORKS API I believe you need to do point.MultiplyTransform with the ModelToSketchTransform.Inverse transform to go from sketch space to model space.