2 Replies Latest reply on May 26, 2014 3:35 AM by Allen Liu

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

    Allen Liu

      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?

                   //???

              }

        • Re: how to get divided segment of the start and end point?
          Artem Taturevych

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

            • Re: how to get divided segment of the start and end point?
              Allen Liu

              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);

                      }