I have an edge and want to identify the point x% from one end or the other.

Is there a native SolidWorks command that does that or will I need to cook up and algorithm?

I have an edge and want to identify the point x% from one end or the other.

Is there a native SolidWorks command that does that or will I need to cook up and algorithm?

Well it is possible, SolidWorks does it from the user interface for reference points. Have a look at the iFeatureManager.InsertReferencePoint method. a bit of a clumsy workaround but you could probably make it work for you by inserting a reference point getting it's coordinates and then deleting it.

Interesting. Yes, it is a work around.

Another workaround. Create a 3D sketch. Convert entity. Segment resulting entity. This is super fast and the uniformity looks good. You can insert up to 100 segments/points. Not only is it possible but SolidWorks is doing a similar thing and it's really fast. I am still going to try to develop a way that is not a workaround though!

Using Edge.Evaluate2 I am getting the results below. What is interesting about this approach is that there seems to be a minimum spacing. The count of point highlighted in the blue sketch below is 100. Once you get a certain spacing between the dots they end up "stacking" on each other. If I edit the sketch and just select one of the points below you'll see there is actually four of them with identical coordinates.

If I use the technique for a small edge like this I'll actually get all the points stacked on top of each other in one spot.

My code looks like this in case anybody sees and error. The Point class is just a class I wrote some time ago to make it easy to get X, Y and Z coordinates rather than using a double array.

I wish this forum had a "code" tag.

foreach (Edge edge in edges)

{

edge.GetCurve();

CurveParamData curveParameters = (CurveParamData)edge.GetCurveParams3();

Vertex startVertex = (Vertex)edge.GetStartVertex();

Point startPoint = new Point((double[])startVertex.GetPoint());Vertex endVertex = (Vertex)edge.GetEndVertex();

Point endPoint = new Point((double[])endVertex.GetPoint());int steps = 100;

double parameterStep = (curveParameters.UMaxValue - curveParameters.UMinValue) / (steps);model.SketchManager.Insert3DSketch(true);

model.ClearSelection2(true);for (int i = 0; i < steps; i++)

{

double param = curveParameters.UMinValue + (parameterStep * i);

double[] currPoint = (double[])edge.Evaluate2(param, 0);

model.SketchManager.CreatePoint(currPoint[0], currPoint[1], currPoint[2]);

}

model.SketchManager.InsertSketch(true);

model.ClearSelection2(true);

}You need to use SetAddToDB. Otherwise when your new point is too close to an existing point (or anything else) it snaps.

Edit: Sorry, it's AddToDB now... It was SetAddToDB when I learned this tidbit myself.

Wow...good catch. This is complicated software. I learn many things new everyday! Thanks for helping!

One way is to use ICurve.GetClosestPointOn to retrieve the U parameter of your point along the curve.

Then call ICurve.GetLength3 twice - once to get the length of the curve from the start point to your point, and then divide that by the full length of the curve.

EDIT: I read your question as "how far along the curve is a given point?"

Maybe you want to know the point that is a given percent along the curve. You could use a similar technique to the above. Choose a U which is x% between the start and end parameters. If the length of the curve between the start parameter and your guess is less than x% of the full length, then increase U. Repeat until a match is reached, within a tolerance.