Creating a Brep 'box' with the "CreateFromBox" method

Hi all,

I am quite new to grasshopper plugins development.

Here is what I am trying to do: I have 8 points (as input arguments) which are the location of a ‘box’ corners (edges are not necessarily either parallel or perpendicular).
I found this Bref method CreateFromBox whose description reads: “Constructs new brep from 8 corner points.” and whose syntax is
"public static Brep CreateFromBox(
IEnumerable corners
)"
I am using the grasshopper C# component. I first created a list of points corners containing the input points and create a Brep using the “CreateFromBox” method and corners as argument. But as experts may expect it didn’t work. I tried other ways which were all fruitless.
Could you please tell me how can I use this method? In case you know a better solution, then I would also be pleased to know it as well. The so generated box is to then to be colored after (if you have a hint for me regarding this, then I will also be happy).

Thank you in advance.


Germain

Usually when your code does not work, it is better to post it here. Then everyone can see what the problem is; now it is guesswork - your description sounds good, but obviously something is wrong.
If you surround your code with ``` (3x back-tick on a line) it looks like this:

public void SolveInstance(IGH_DataAccess da)
{
// your code here...
}

Thanks for the reply. Here is the code:

private void RunScript(Point3d P0, Point3d P1, Point3d P2, Point3d P3, Point3d P4, Point3d P5, Point3d P6, Point3d P7, ref object A)
  {

    List<Point3d> corners = new List<Point3d>();
    corners.Add(P0);
    corners.Add(P1);
    corners.Add(P2);
    corners.Add(P3);
    corners.Add(P4);
    corners.Add(P5);
    corners.Add(P6);
    corners.Add(P7);

    Brep box = new Brep();
    box = new CreateFromBox(corners);
    
    A = box;

  }

Try this:

Brep box = Rhino.Geometry.Brep.CreateFromBox(corners);
A = box;
1 Like

Thank you very much Matthew, it did work.