Of course. I tried to replicate all the steps since the beginning, a simple IGES file. The O11_Intersect.cs is a simplified version of my command (without safety checks and assuming we are working with the three surfaces of the PS_Top file).
Rather than using BrepFace.ToBrep(), which creates a new Brep from the face’s underlying surface, try using BrepFace.DuplicateFace, which creates a new Brep from the face, thus including things like trims, loops, etc.
This seems to work well on your model:
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var go = new GetObject();
go.SetCommandPrompt("Please select the three surfaces");
go.GeometryFilter = ObjectType.Surface;
go.SubObjectSelect = false;
go.GetMultiple(3, 3);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
var in_breps = new List<Brep>(3);
foreach (var objref in go.Objects())
{
var in_brep = objref.Brep();
if (null == in_brep)
return Result.Failure;
in_breps.Add(in_brep);
}
var join_tol = doc.ModelAbsoluteTolerance * 2.1;
var out_breps = Brep.JoinBreps(in_breps, join_tol);
if (1 != out_breps.Length)
return Result.Failure;
var out_brep = out_breps[0];
var plane = new Plane(new Point3d(0, 0, -4750), Vector3d.ZAxis);
var out_curves = new List<Curve>();
foreach (var face in out_brep.Faces)
{
var brep = face.DuplicateFace(false);
if (null != brep)
{
var contours = Brep.CreateContourCurves(brep, plane);
if (null != contours && contours.Length > 0)
out_curves.AddRange(contours);
}
}
foreach (var curve in out_curves)
doc.Objects.AddCurve(curve);
foreach (var objref in go.Objects())
doc.Objects.Delete(objref, true);
doc.Objects.AddBrep(out_brep);
doc.Views.Redraw();
return Result.Success;
}