algorithmic modeling for Rhino
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];
}
Tags:
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];
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by