Grasshopper

algorithmic modeling for Rhino

Hi everybody!

I am trying to make these openings in a box but I started to have several problems. I am using the domains of the box face to define the dimension of the windows (sure there´s a simpler way ;-)). So when writing:

private void RunScript(Brep room, ref object window_edge, ref object window_edge_BBox, ref object window_edge_ToBrep, ref object face_frame, ref object difference) {

   List<Brep> face = new List<Brep>();
    face.Add(room.Faces[1].DuplicateFace(false));

    //extract the domains of the face
    Interval domUFace = new Interval();
    Interval domVFace = new Interval();
    domUFace = room.Faces[1].Domain(0);
    domVFace = room.Faces[1].Domain(1);

    //extract the plane at the origin
    Plane planeOrigin = new Plane();
    room.Faces[1].FrameAt(0, 0, out planeOrigin);

    // build the window frame from the domains
    Interval domUWindow = new Interval();
    domUWindow[0] = domUFace[0] + domUFace.Length / 4;
    domUWindow[1] = domUFace[1] - domUFace.Length / 4;
    Interval domVWindow = new Interval();
    domVWindow[0] = domVFace[0] + domVFace.Length / 4;
    domVWindow[1] = domVFace[1] - domVFace.Length / 4;

    Rectangle3d windowEdge = new Rectangle3d(planeOrigin, domUWindow, domVWindow);

    List<Brep> window = new List<Brep>();
    window.Add(windowEdge.BoundingBox.ToBrep());

    //solid difference
    List<Brep[]> dif = new List<Brep[]>();
    dif.Add(Brep.CreateBooleanDifference(face, window, 0.0));
   
   //outputs
    face_frame = face;
    window_edge = windowEdge;
    window_edge_BBox = windowEdge.BoundingBox;
    window_edge_ToBrep = windowEdge.BoundingBox.ToBrep();

difference = dif[0];
}

I don´t get the boolean difference. Is it because they are plane surfaces? I tried to use Grasshopper´s solid difference on plane surfaces and it worked. I am attaching an image.

Does anybody know what´s going on and how I could fix it?

Thanks!



Views: 1059

Replies to This Discussion

Hi Miguel,

it seems like you could accomplish this without resorting to Solid Booleans and BoundingBox hacks.
What about this:

private void RunScript(Brep room, ref object window_edge, ref object face_frame)
{
  BrepFace face = room.Faces[1];

  //extract the domains of the face
  Interval face_u = face.Domain(0);
  Interval face_v = face.Domain(1);

  //Compute the domains of the window gap
  Interval gap_u = face_u.ParameterIntervalAt(new Interval(0.25, 0.75));
  Interval gap_v = face_v.ParameterIntervalAt(new Interval(0.25, 0.75));

  //extract the plane at the origin
  Plane face_plane;
  face.FrameAt(face_u.Min, face_v.Min, out face_plane);

  //Create the rectangles
  Rectangle3d face_edge = new Rectangle3d(face_plane, face_u, face_v);
  window_edge = new Rectangle3d(face_plane, gap_u, gap_v);

  //Create a collection of planar curves
  CurveList loops = new CurveList();
  loops.Add(face_edge.ToNurbsCurve());
  loops.Add(((Rectangle3d)window_edge).ToNurbsCurve());

  //Create planar breps
  Brep[] walls = Brep.CreatePlanarBreps(loops);
  if (walls == null) { return; }

  //Store the first result (there should only be one)
  face_frame = walls[0];
}


--
David Rutten
david@mcneel.com
Seattle, WA
Wow, David, thanks a lot for your reply!
It all seems much more easy now.

Just a couple of questions about your code:

- ParameterIntervalAt, as I see in the rhinocommon help file, remaps whatever values of interval you input from 0 to 1 to the target domain, in this case, of the surface, isn´t it?

- I didn´t find a method to extrude surfaces. CreateExtrusion only seem to accept curves as profile. So, how could I extrude the resulting surface/brep?

And for future usage, I figure that planar boolean differences tend to be difficult to solve.

Thanks again :-)

Cheers!
The code above creates profile curves before creating the planar surface. You could use those for the extrusion.
Hi Vicente,

In reply to you, I meant to extrude the Breps that come from CreatePlanarBreps, which is created by the exterior boundary and the opening curve.

I think you can´t use as profile curves to extrude a list or array of curves, only one of them.

Thanks for your response anyway!
:-)
Extruding Breps is basically a process of

1) finding all naked edges
2) extrude all naked edges into sides
3) copy + move the original brep along the extrusion vector
4) join everything together.

We should probably offer this functionality directly inside the SDK.

--
David Rutten
david@mcneel.com
Seattle, WA
Thanks, David, it would be great to have that functionality in the future. In the meantime, I´ll follow the steps you mentioned.

Cheers!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service