Surface from ON_Brep

Hi

I have Problem with getting Surface from Brep, there are some Surface which is not Right shape.

for example, I try to create a Cylinder and test with putting a Surface in RhinoDoc but the Surface from top is not a circle Surface as it should be. I am sure that I miss something for the Code but dont know what

Here is my code

var cylinder = new Cylinder(new Circle(10), 20);
var brep = cylinder.ToBrep(true,true);
var surface = brep.Faces.ElementAt(1);
doc.Objects.AddSurface(surface);

Mimy

The top and bottom faces are trimmed and you are adding the surfaces untrimmed. Try this

var faceBrep = brep.Faces.ElementAt(1).ToBrep(); // duplicate a face as BRep
doc.Objects.AddBrep(faceBrep); 

Hi Menno,

Thanks for answer.
The Brep Face still untrimmed.

Oops, my mistake. Don’t use .ToBrep() use .DuplicateFace(false)

var faceBrep = brep.Faces.ElementAt(1).DuplicateFace(false); // duplicate a face as BRep
doc.Objects.AddBrep(faceBrep); 

If you look at the list of methods available for the BrepFace class (https://developer.rhino3d.com/api/RhinoCommon/html/Methods_T_Rhino_Geometry_BrepFace.htm)

You see that a lot of them are “inherited from Surface”. All of these methods will not take trimming information into account.