Such as the title,I try to put a lid for a square tube but I can’t find the function _cap in rhinocommon , I tried CapPlanerHoles or create the top and bottom surface and join them,but none of thoes work
here are my code:
protected override void SolveInstance(IGH_DataAccess DA)
{
Curve C=null ;
Curve C_rec_start = null;
Curve C_rec_end = null;
Plane P = new Plane();
double H = 0;
double W = 0;
if (!DA.GetData(0, ref C)) return;
//if (!DA.GetData(1, ref P)) return;
if (!DA.GetData(1, ref H)) return;
if (!DA.GetData(2, ref W)) return;
if(C.TryGetPlane(out Plane P2))
{
Plane P3 = new Plane(P2.Origin, P2.XAxis, P2.ZAxis);
double angle1 = Vector3d.VectorAngle(C.TangentAtStart, P3.Normal);
double angle2 = Vector3d.VectorAngle(C.TangentAtEnd, P3.Normal);
if (!P3.Rotate(angle1, P2.ZAxis, P3.Origin)) return;
if (!P3.Rotate(angle2, P2.ZAxis, P3.Origin)) return;
P3.Origin = C.PointAtStart;
Plane P4 = P3;
P4.Origin = C.PointAtEnd;
Rectangle3d rec_start = new Rectangle3d(P3, W, H);
GH_Convert.ToCurve(rec_start, ref C_rec_start, GH_Conversion.Both);
Rectangle3d rec_end = new Rectangle3d(P3, W, H);
GH_Convert.ToCurve(rec_end, ref C_rec_end, GH_Conversion.Both);
Curve[] C_sweep = new Curve[2] { C_rec_start, C_rec_end };
Brep[] B_start = Brep.CreatePlanarBreps(C_rec_start, 0.01);
Brep[] B_end = Brep.CreatePlanarBreps(C_rec_start, 0.01);
Brep[] B = Brep.CreateFromSweep(C, C_sweep, true, 0.01);
B = Brep.JoinBreps(B, 0.01);
Brep[] B_combine = new Brep[3] { B_end[0], B_end[0], B[0] };
B_combine = Brep.JoinBreps(B_combine, 0.01);
DA.SetData(0, B_start[0]);
}
}