Hello everyone,
I’m developing a new plugin for Rhino, using Rhinocommon SDK and Visual Studio .NET C#.
I’m trying to convert a Trimmed Brep Face to our internal library NURBS format, but I get a surface that is different from the original, since it has several unwanted extensions.
When using the Rhinocommon function “Brep.CopyTrimCurves(face, surface, tolerance)“ I get the same wrong result.
If I export the surface as IGES file and reimport, then, on the new imported surface, everything works fine.
The attached image shows the original surface (green colored) and the wrong surface (red colored), it is easy to see the unwanted extensions.
In the 3dm attached file, there are: the original surface; the converted (wrong) surface; and the surface imported after exporting the original surface and for wich the conversion works fine.
Thanks.
Donato Bevilacqua.
Following a sample code, producing the wrong surface:
public void DupBrepWithRhinoCopyTrimCurves()
{
var doc = RhinoDoc.ActiveDoc;
var att = new Rhino.DocObjects.ObjectAttributes();
att.ColorSource = ObjectColorSource.ColorFromObject;
// select a surface
var gs = new GetObject();
gs.SetCommandPrompt("select surface");
gs.GeometryFilter = ObjectType.Surface;
gs.DisablePreSelect();
gs.SubObjectSelect = true;
gs.Get();
if (gs.CommandResult() != Result.Success)
{
Rhino.UI.Dialogs.ShowMessageBox("Surface selection failed!", "surface selection");
return;
}
// get the selected face
var face = gs.Object(0).Face();
Brep selectedBrep = gs.Object(0).Brep();
var surface = face.UnderlyingSurface().ToNurbsSurface();
//var surface = face.ToNurbsSurface();
var newBrep = Rhino.Geometry.Brep.CopyTrimCurves(face, surface, 1e-6);
if (newBrep != null)
{
att.Name = "NEW trimmed BREP";
att.ObjectColor = System.Drawing.Color.DarkGreen;
doc.Objects.AddBrep(newBrep, att);
}
}
Brep Face Conversion.3dm (363.9 KB)