how to get divided segment of the start and end point?

When I selected a edge and got total distance.

How to get divided segment of the start and end point?

Can you give me a hand?

private void CalPoint(int segment)
        {
            double[] vStarPoint = new double[3];
            double[] vEndPoint = new double[3];
            Edge swedge = _edgeList[0]; //selected edge
           
            Curve swcur = (Curve)swedge.GetCurve();
            CurveParamData curparam = (CurveParamData)swedge.GetCurveParams3();

            //edge total length
            Double edgelen = (Double)swcur.GetLength3(curparam.UMinValue, curparam.UMaxValue) * 1000;

            Vertex startVertex = swedge.GetStartVertex();
            Vertex endVertex = swedge.GetEndVertex();

            //get Start and End Vertex points.
            vStarPoint = startVertex.GetPoint();
            vEndPoint = endVertex.GetPoint();

            //calculate equidistant length's segment
            Double tempLen = edgelen / segment;

            //How to get  divided  segment start and end point?

             //???

        }

SolidworksApi macros
Answers 2
AT
AT 2014-05-24 Best Answer

You need to evaluate the edge at parameter. Try this method: Edge::Evaluate2.

SF
SF 2014-05-26

I rewrite new code. but then result is not correct.  Could you help me to point out what's wrong?

private void CalPoint(int segment)
        {
            double[] vStarPoint = new double[3];
            double[] vEndPoint = new double[3];
            Edge swedge = _edgeList[0];

            if (swedge == null) return;
           
            Curve swcur = (Curve)swedge.GetCurve();
            CurveParamData curparam = (CurveParamData)swedge.GetCurveParams3();

            //edge total length
            Double edgelen = (Double)swcur.GetLength3(curparam.UMinValue, curparam.UMaxValue) * 1000;

            Vertex startVertex = swedge.GetStartVertex();
            Vertex endVertex = swedge.GetEndVertex();

            //get Start and End Vertex points.
            vStarPoint = startVertex.GetPoint();
            vEndPoint = endVertex.GetPoint();

            //calculate equidistant length's segment
            Double tempLen = edgelen / segment;
          
            double[] vSegPoint=new double[3];
            IModelDoc2 pDoc;
            pDoc = (IModelDoc2)_addin.SwApp.ActiveDoc;
            pDoc.SketchManager.Insert3DSketch(true);
            pDoc.SketchManager.AddToDB = true;
            for (int i = 1; i < segment; i++)
            {
                vSegPoint = (double[])swedge.Evaluate2(tempLen * i, 0);
                System.Windows.Forms.MessageBox.Show("vPoint.X[" + vSegPoint[0] + "],vPoint.Y[" + vSegPoint[1] + "],vPoint.Z[" + vSegPoint[2] + "]");
                pDoc.SketchManager.CreatePoint(vSegPoint[0], vSegPoint[1], vSegPoint[2]);
                            }
            pDoc.SketchManager.AddToDB = false;
            pDoc.SketchManager.Insert3DSketch(true);

        }