// Hello C# World!
/*
One question : Someone knows how to fix this error : Error (CS0029): Cannot implicitly convert type ‘Rhino.Geometry.Brep’ to ‘Rhino.Geometry.Brep’ (line 90)forLoop-GridOfBreps.gh (10.1 KB) /
/
I will appreciate any explanation about how to use this method, thanks in advance!
*/
private void RunScript(double x, double y, double z, int n, double w, double h, double g, ref object A, ref object B, ref object C, ref object D)
{
//Global variables
// x, y, z // Position
int nCells = n; // how many Breps
if (nCells < 1){nCells = 1;}
double width = w;
double height = width;
double gap = g; // space between
// Empty List to collect our geometry
List <Rectangle3d> gridRectangles = new List <Rectangle3d>();
List<NurbsCurve> myCurves = new List<NurbsCurve>();
List<Brep> myBrepSurfaces = new List<Brep>();
List<Extrusion> collectBreps = new List<Extrusion>();
// for loop to generete a 2D grid of Breps
for (int i = 0; i < nCells; i++)
{
Point3d point = new Point3d((x + i * (width + gap)), y, z);
Vector3d vectNormal = new Vector3d(Vector3d.ZAxis);
Plane myPlane = new Plane(point, vectNormal);
// Grid of of Rectangles
Rectangle3d myRect = new Rectangle3d(myPlane, width, height);
gridRectangles.Add(myRect);
// Convert the Rectangles to Nurbs
// https://developer.rhino3d.com/5/api/RhinoCommon/html/M_Rhino_Geometry_Rectangle3d_ToNurbsCurve.htm
NurbsCurve myCurve = gridRectangles[i].ToNurbsCurve();
myCurves.Add(myCurve);
// Create a Planar Brep Surface
// Brep.CreatePlanarBreps Method
// https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_CreatePlanarBreps_5.htm
Brep myBrepSurface = Brep.CreatePlanarBreps(myCurve, 0.001); // Why this line does not work?
myBrepSurfaces.Add(myBrepSurface);
// Extrude NurbsCurve to a Closed Brep
// https://developer.rhino3d.com/5/api/RhinoCommon/html/M_Rhino_Geometry_Extrusion_Create.htm
double extrudeHeight = h;//1.0;
Extrusion myExtrusion = Extrusion.Create(myCurve, extrudeHeight, true);
collectBreps.Add(myExtrusion);
}
A = gridRectangles;
B = myCurves;
C = myBrepSurfaces;
D = collectBreps;
}