I’m trying to write a C# script that works on one face of a brep - I need to extract the plane of a planar face and check to see if some points are on it - and if some other faces are coplanar with it. But is there any way to reference a brep face in to Grasshopper? The obvious ways - ctrl-shift selecting in Rhino window to reference in Surface or brep primitive - don’t work.
I know I can explode the brep and access the faces individually - and could then use a number slider for instance to select the right face - but I was wondering if there was a better way to do this?
You don’t need to explode the Brep, just use the Deconstruct Brep component and it will give you the faces. But if you are looking for a C# solution you probably should post to the Grasshopper developer category.
Anyway … outline in deph what could be the desired workflow plus post an indicative test case (BTW: if you want some sort of aid from me do that in R5 format).
Hey thanks for your reply. I’m fairly new to GH and just beginning to learn C# - I would be very interested in learning more about Brep Connectivity - is that screen shot from a tutorial or something?
But my actual question is not C# related - I’d like to let the Grasshopper user of my C# component specify a face of a brep. I.e. within Grasshopper is there a way to reference in one single face from a Brep in Rhino?
Ways I’ve considered: 1. reference in full brep and use a Grasshopper number slider or “List item” to manually select. 2. surfaces will always be planar so have the user reference in 3 points on that plane - then check surfaces one by one for coplanarity. (Both of these will work just wondering if there is a more direct way).
(I’ve never heard of R5 format - is this a programming term?)
I don’t know if this is what you want, but you can store the brep in a Brep container, run it through Deconstruct Brep, and then either run it through the Cherry Picker or List Item with a slider attached to get the face of a Brep.
This is a very manual operation. The Grasshopper user will have to right-click the Brep container to select objects in Rhino per “select one Brep”. Then they will have to update the number slider so that the domain max is as high as the number of faces in the Brep. Unfortunately, there is no domain slider in Grasshopper. Why is beyond me.
Check the referenced Breps and Points for planarity by passing the points and the faces of the breps as planes into Plane Closest Point. The tree branches with distances that sum to zero are the faces planar with the points. This will retrieve the faces planar with the points without reference to which brep they are from (if multiple breps were referenced in the brep container) although you could work backwards to that information if you wanted to.
Alright, so I tested something. If you are willing to use the Grasshopper Player, you can use a Get Geometry component with only Surfaces as a selectable geometry:
Get the Faces (List< BrepFace > faces = brep.Faces.ToList()); Or use some LINQ to query the collection against some filter(s) - the Where (x=>x …) thing.
Check the index from a slider (if(index >= faces.Count) index = faces.Count-1);
Get your face (BrepFace face = faces[index]); Or use any check(s)/filter(s) more (like: is it planar? is it adjacent to some other Face? is it a cat? maybe is a dog? etc etc).