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:
This is what I need:
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
Tags:
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
Hallo Florian.
Just what I needed, thanks a lot! It works perfect in my script.
Cheers, Eirik
Glad it works!
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
© 2024 Created by Scott Davidson. Powered by