Trimming Nurbs Surfaces in the parameter space

Hi all,

I am looking to programmatically trim Nurbs surfaces using curves that would be defined in the parameter space (read: uv plan) of the Nurbs surfaces rather than in the physical space. Is it possible/easy to do using RhinoCommon?


More information on what you have and what you trying to do (and why) would be helpful. I’d say yes if you were using the C++ SDK. But I’ll need more info to give you a good answer for RhinoCommon…

In Rhino itself I’d use FlowAlongSrf to put the trim curve onto the surface.

Create a rectangular surface using Plane which would be the nominal surface in parameter space. xy for the plane will correspond to uv of the target surface. Create the desired trim curve on the plane. Then use FlowAlongSrf. Select the curve to flowed onto the surface, the rectangular planar surface as the base surface, and the target surface.

Trim the surface with the curve on the surface.

Thanks for the quick answers.

@davidcockey yes, your strategy works for modeling purposes (thank you btw, I did not know the command) but I am really looking to do this with code.

@dale I am trying to map aperture patterns that are input by the user. The reason I am trying to do this programmatically is because I want to link it to an optimization procedure acting on the trimming pattern in the parameter space (much easier to deal with + the analysis formulation relies heavily on the parameter space). I have little experience with C++ while I am used to coding in C#, hence my preference for RhinoCommon.

Once you’ve calculated your 2D parameter space curves, you can compute 3D curves that are the composites of the 2D curve and the surface map using Rhino.Geometry.Surface.Pushup. With these curves, you can begin to build the Brep (e.g. trimmed surface).

If your surface is planar and the curve are coplanar with the surface, then you can quickly trim the Brep using Rhino.Geometry.Brep.Loops.AddPlanarFaceLoop. If not, then you will need to thru the more time consuming task of extruding the curves into Breps and then trimming the source Brep with Rhino.Geometry.Brep.Trim.

Let me know if you have any questions.

Thanks @dale, I’ll try that.

@dale the strategy you suggested works but is too time-consuming. Do you think it would be possible to do without the need for extrusions using openNurbs for .Net? If not, I’m ready to switch to the C++ SDK (in this case, do you have any advice on where to start?)


Like I said before, we need more information in order to provide anything but some vague tips. Can post an example of what you are trying to create?

@dale I have attached a picture that may help you understand what I am trying to achieve. Long story short, I am trying to optimize the number and shapes of holes on a surface for some objective function. In order to do that I need to change the geometry of the holes at every step of my optimization loop. Specifically, I need to modify the shapes of the ‘holes’ in the parameter space rather than in the physical space so I need a way to have them linked together. In the image that you see here, I have been able to extract the parameter space of a given surface but I can’t seem to be able to reverse the process i.e. trim a surface using a parameter space with trimming curves. The way I have been trying to do it was to create new loops and trims in the brep (the surface cast as a brep) using the 2d curves in the parameter space but it does not seem to work.

I hope this made things clearer. Thanks

More specific example:
why doesn’t this method create a trimmed Brep (assuming the curve is a closed curve defined in the 0,1 0,1 domain in Rhino)
public static Brep ConstructBrep(Surface s, Curve c)
Brep brep = s.ToBrep();

        //reparametrize brep (2d trimming curve to select has to be defined in the square defined by (0,0,0) and (0,1,0)
        brep.Faces[0].SetDomain(0, new Interval(0,1));
        brep.Faces[0].SetDomain(1, new Interval(0,1));

        Curve c3 = s.Pushup(c, 0.01);

        int indexedge = brep.AddEdgeCurve(c3);
        int indextrim = brep.AddTrimCurve(c);
        //surface -> 1 face
        BrepLoop innerLoop = brep.Loops.Add(BrepLoopType.Inner, brep.Faces[0]);
        BrepEdge innerEdge = brep.Edges.Add(indexedge);
        BrepTrim innerTrim = brep.Trims.Add(innerEdge, false, innerLoop, indextrim);

        return brep;


I guess I’d be curious to know more about this.

Another approach you can take is to create a Rhino.Geometry.Brep object from your surface and then use Rhino.Geometry.BrepFace.Split. You will need to push up your 2d curves into 3d space in order to use this function.

Regarding the C++ SDK, your more than welcome to explore this toolkit. But rolling your own Brep is not for the faint of heart…

Ok, I’ll do that. Thank you for all your help @dale!