Grasshopper

algorithmic modeling for Rhino

I need to union closed curves in a script. I have several 2d shapes that sometime intersect and when they do I need to create their outline/boundary.

I found a solution/hack in Grasshopper, but I need this scripted. Any idea how to resolve it?

Here is an example:

starting shapes.

This is what I need:

Closed shape outline curves.

The Grasshopper fix:

My thoughts was to script it like this:

create Breps from the Curves

Join or Union the Breps

Use Curve.JoinCurves on the resulting Brep outlines: Brep.GetWireframe(-1)

Unfortunately, neither the Brep.CreateBooleanUnion() nor the Brep.JoinBreps() functions return properly joined Breps.

How can I recreate my Grasshopper solution in Script or is there another way to achieve this?

Cheers, Eirik

Views: 5898

Attachments:

Replies to This Discussion

Hi Erik,

nice hack, but actually there is a method for this...in grasshopper its called region union...in RhinoCommon its the method Curve.CreateBooleanUnion(List of curves), which returns a list of curves again.

Since you have only planar and closed curves (am i right with this?), this is the proper way. I've made you an example in C#. You can do the same in VB and Python, tell me if you need help with translation ;-)

 

private void RunScript(List<Curve> C, ref object region) {
region = Curve.CreateBooleanUnion(C);
}


this is the result:

attached is the gh file.

Cheers
FF

Attachments:

Hallo Florian.

Just what I needed, thanks a lot! It works perfect in my script.

Cheers, Eirik

Glad it works!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service