2 Replies Latest reply on Feb 4, 2015 4:37 AM by Dennis Moll

    ISurface::IntersectCurve2 Constructor Problem

    Dennis Moll

      Hello together,

       

      I need to find the intersection point between a plane surface and an edge/curve. The plan was to do it with the method ISurface::IntersectCurve2 which can be found here: 2012 SolidWorks API Help - IIntersectCurve2 Method (ISurface)

       

      I am programming in C# so the method expects ref double and out double as input parameters. But there also stands that it needs to be an array of doubles which can't be the case or am i wrong? I am kind of new to programming. The same goes for the also needed 2012 SolidWorks API Help - GetIntersectCurveCount2 Method (ISurface)

       

      There is an example in the help 2012 SolidWorks API Help - Get Intersecting Face and Edge Example (VBA)  but the constructors doesn't match each other. I also couldn't figure out why vCurveBounds is in brackets. It is the old version of the function but it needs the same input. I hope you can help me with a solution for my problem or another method.

       

      Sincerely

      Dennis

        • Re: ISurface::IntersectCurve2 Constructor Problem
          Taro Yamada

          I recommend you to use IntersectCurve2 Method.

          Below is example. (curve is ICurve, and surface is ISurface.)

           

          double sp, ep;

          bool closed, periodic;

          curve.GetEndParams(out sp, out ep, out closed, out periodic);

          double[] s_pt = curve.Evaluate(sp);

          double[] e_pt = curve.Evaluate(ep);

          double[] bounds = new double[6] { s_pt[0], s_pt[1], s_pt[2], e_pt[0], e_pt[1], e_pt[2] };

          object obj_bounds = bounds;

          int intersect_n = surface.GetIntersectCurveCount2(curve, ref bounds[0]);

          object intersect_pt = new double[intersect_n * 3];

          object intersect_t = new double[intersect_n];

          object intersect_u = new double[intersect_n * 2];

          surface.IntersectCurve2(curve, obj_bounds, ref intersect_pt, ref intersect_t, ref intersect_u);

            • Re: ISurface::IntersectCurve2 Constructor Problem
              Dennis Moll

              Thanks for the reply. As you said IntersectCurve2 is the solution. IIntersectCurve2 isn't executable in C#. That is is the final solution including the casting:

               

              intersectionEdge = (Edge)(aAdvancedFaces[lastPoint.AdjacentFaces[j]].Face.GetEdges())[l];

              Curve intersectionCurve = intersectionEdge.GetCurve();

              double[] edgeBounds;

              edgeBounds = new double[6] { intersectionEdge.GetCurveParams3().StartPoint[0], intersectionEdge.GetCurveParams3().StartPoint[1], intersectionEdge.GetCurveParams3().StartPoint[2], intersectionEdge.GetCurveParams3().EndPoint[0], intersectionEdge.GetCurveParams3().EndPoint[1], intersectionEdge.GetCurveParams3().EndPoint[2] };

              object vTArray = new object();

              object vUvArray = new object();

              object edgePointArray = new object();

              bool test = intersectionSurface.IntersectCurve2(intersectionCurve, edgeBounds, ref edgePointArray, ref vTArray, ref vUvArray);

              edgePointArray = (double[])edgePointArray;