hi guys .As shown in the figure, I want to use curve to drill holes in the surface. What function should I use to achieve this goal .Can you provide some useful solutions?
hole.3dm (298.7 KB)
above is the test file and I have tried some methods But can not work
GetObject go = new GetObject();
go.GeometryFilter = ObjectType.Brep | ObjectType.Extrusion;
go.AcceptNumber(true, false);
go.SetCommandPrompt("select Brep");
GetResult Res = go.GetMultiple(1, 0);
if (Res == GetResult.Cancel || go.ObjectCount == 0)
return Result.Failure;
List<ObjRef> SelectedBoundaryRefs = new List<ObjRef>();
Result Res2 = RhinoGet.GetMultipleObjects("select curve", true, ObjectType.Curve, out ObjRef[] CeilBoundaryRefs);
if (Res2 == Result.Success)
{
SelectedBoundaryRefs.AddRange(CeilBoundaryRefs);
}
SelectedBoundaryRefs = SelectedBoundaryRefs.Distinct<ObjRef>(new ObjRefComparer()).ToList();
if (SelectedBoundaryRefs.Count == 0)
{
return Result.Failure;
}
else
{
double tolerance = Doc.ActiveDoc.ModelAbsoluteTolerance;
RhinoObject brepobj = go.Objects()[0].Object();
Extrusion Extr = brepobj.Geometry as Extrusion;
Brep br = Extr.ToBrep(false);
Curve cur = SelectedBoundaryRefs[0].Curve();
//method1 res Length=0
Brep[] breps = Rhino.Geometry.Brep.CreatePlanarBreps(cur, tolerance);
Brep curbrep = breps[0];
Brep[] res = br.Trim(curbrep, tolerance);
if(res.Length>0)
{
doc.Objects.Add(res[0]);
}
else
{
doc.Objects.Add(curbrep);
}
//method2 CeilPiece Length=1 But the result is not what i want
Surface surface = Extrusion.CreateExtrusion(cur, new Vector3d(0,0,-10));
Rhino.Geometry.Brep brep = Rhino.Geometry.Brep.CreateFromSurface(surface);
Brep Boolgeo = brep.CapPlanarHoles(tolerance);
Brep[] CeilPiece = Brep.CreateBooleanDifference(br, Boolgeo, tolerance);
if(CeilPiece.Length>0)
{
doc.Objects.Add(CeilPiece[0]);
}
else
{
doc.Objects.Add(Boolgeo);
}
}
I urgently need your help . thank you