Grasshopper

algorithmic modeling for Rhino

Is it possible to write a C# code to perform a solid difference on two Brep sets? the grasshopper component ( Solid Difference) works very well but the sequence of the resulted items is not in order ( i think it is a tolerance issue), that's why I was searching for a way to write it inside C#. 

the first image shows the two sets of solid intersection inputs ( 1st brep and 2nd Brep sets)

the second image shows the result I got from using solid intersection component. the difference result items are not in the right order ( the right order is shown in black numbers and arrows) 

Question.gh

Views: 989

Replies to This Discussion

Yes it is. Grasshopper in fact does this using C# code (or maybe equivalent VB code, can't remember now specifically).

What you have to do is keep a list of breps which is updated on every solid operation. Looks something like this:

List<Brep> shapes = ...;

List<Brep> cutters = ...;

foreach (Brep cutter in cutters)

{

  List<Brep> newShapes = new List<Brep>();

  foreach (Brep shape in shapes)

  {

    Brep[] results = SolidDifference(shape, cutter);

    newShapes.AddRange(results);

  }

  shapes = newShapes;

}

You'll get the same ordering problems though. The order in which the Breps are returned from the RhinoCommon solid boolean functions is not meaningful. You can however sort them yourself afterwards of course. Looks like you want to sort them from highest bounding box z-value to lowest.

Indeed ... but since these are obviously due to some kind of parametric "pre" processing (for doing  a "waffle" kind of result as it appears) the order of pieces (from shapes) is easy to master (and the number/order of cutters).

Thank you a lot for the explanation. I wrote the C# code and as you mentioned the ordering problem still exists and for this case sorting them from highest z value to lowest will bring the right order.  

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service