Curve from Object (Section)

Hi
is there any how to demonstrate implementing Section via Rhinncommon?

Hi,

How about Intersection BrepPlane?

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Intersect_Intersection_BrepPlane.htm

Thanks for the reply, I’ve seen that, but I want to be able to select 2 different points on a surface and then rhino extract that curve from object/surface…exactly like section command does in rhino…

any idea?

maybe some combination of those:
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Input_Custom_GetPoint.htm
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_LineCurve__ctor_5.htm
https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_ViewportInfo_CameraZ.htm
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Plane__ctor_2.htm
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_CreateContourCurves.htm
you may need to make some dynamic draw magic to make that line curve dynamically showing before second point is chosen.

if you want to have finite line, maybe extrude it to surface instead and make intersection.

Thanks Lukas,
First I thought I have to use this Surface.InterpolatedCurveOnSurfaceUV Method, but the output curve is not a curve on surface.
Then your post pointed me to use LineCurve + Intersection.CurveBrep Method but no curve will returned. I have used Contour before…its returning so many curves that i dont need.
Let me clarify, I have 2 curves on a Brep, I need to extract a curve of brep from startpoint of first curve and endpoint of 2nd curve.

A native Rhino Section is basically a line projected in the active viewport’s normal direction onto breps/meshes. You can use the same procedure in RhinoCommon -

  1. Use 2 points to create a LineCurve via RhinoCommon
  2. Project the line curve to the brep or mesh with Curve.ProjectToBrep() or Curve.ProjectToMesh()
  3. The return is a list of curves that represent the section - you can choose to join them with Curve.JoinCurves()
2 Likes

Thank you for reply Mitch. You are right, but dunno why I don’t get any curve back?!!

     //after getting objects from user
            Brep face = go.Object(0).Brep();
            Point3d startpt = firstcrv.PointAtEnd;
            Point3d endpt = secondcrv.PointAtStart;

            Line line = new Line(endpt, startpt);
            LineCurve linecurve = new LineCurve(line);
            Curve[] crvs = LineCurve.ProjectToBrep(linecurve, face, line.Direction, 1);
            CustomDisplay display = new CustomDisplay(true);
            foreach (Curve crv in crvs)
                display.AddCurve(crv);            
            doc.Views.Redraw();

you should have direction vector specified as normal to: for example viewport, construction plane or whichever direction you want to project. In your code you choose direction as extension of line, which I imagine is not what you really want to do.

1 Like

Yes, thank you…I used Brep.closestpoint to get normal…Thank you again.