GH Python - Intersect List of Curves and get a List of Point3D


i’am wondering how i could get a List of Point3D out of a List of intersection_events:

# Calculate the intersection
intersection_tolerance = 0.001
overlap_tolerance = 0.0
for i in range(0,len(curves)):
_ for j in range(0,len(circle)):_
_ events = rg.Intersect.Intersection.CurveCurve(curves[i],circle[j], intersection_tolerance, overlap_tolerance)_
_ PointA.append(events)_

So the result should be, get a List of Point3D from the Intersections between a list of circles and a list of curves… how can i do that?

thank you for the help!


Have a look at the CurveIntersections class. Which should be the type of your _events variable (it’s always easier to help/troubleshoot if you provide a file).

1 Like

Yes you are right.
So here is a Snip of my file.

gh python (4.9 KB)

So the Problem is very simple. For the input i have

  1. Polyline Curve (4) - ListAccess - TypeHint: Curve
  2. Circles (4) - ListAccess - TypeHint: Curve

do you have any ideas? Since your referenced link is just for C# and VB i’am not sure
how it could help me!

Thanks alot!

You’re using the RhinoCommon API (i.e. import Rhino) these are the RhinoCommon API docs, linking to the class/type that is returned from the Rhino.Geometry.Intersect.Intersection.CurveCurvemethod you are implementing.

Afraid I’m away from a Rhino-system, but you would iterate the events like so:

for i in range(events.Count):
    ccx = events.Item[i]

Where ccx is now an instance of the IntersectionEvent class, which enables you to query the intersection type, points, parameters on the curves etc.

Hope that helps and isn’t too confusing!

1 Like

Hey thanks for the Help!

since i followed your instructions there is still something missing. (Another problem)
And im very confused what my mistake could be:

So i have 12 “Line Like Curve” but this could be polylines aswell or curves in general! (I exploded them since the Intersect_Method did not seem to find all the intersections:

The reason for me (i think) is clear… if i iterate the events with a different number of Items in the list… this could cause problems… but till now, i dont see my mistake…may you help me again?

Thank you very much!

You can use type(), help()and dir() to directly inspect variables in code to figure out which type they are, which methods/properties they expose etc. The larger issue is that you appear to jump out of the intersection scope from line 19 to 20 (meaning that events at line 21 will only be that last iteration in the nested loop you start at line 17-18 (i.e. you keep overwriting the events variable here. I might also simply not be getting the logic :man_shrugging:

1 Like

From the beginning:

Since the Method of CurveCurve intersection does not work with “lists”… i need to iterate the elements… right?
And since i want to get ALL intersections of to sets of curves, in this case curves and circles, i need to somehow bring every element that intersects with one out of the other list together.

My code might be not logic but i dont have a better idea right now! :smiley:
What would be your solution for that Problem? Intersecting the given geometry?

Hi Simon, managed to have a look at your code now. If I understood what you’re trying to achieve correctly, you could get all the intersection points like so: (5.4 KB)

There are many other ways of implementing the same base logic here (i.e. that are more traditional C-like by iterating over the indices etc), but this is probably a pretty good (or at least terse) Python-ish approch.

Hope that helps and apologies for adding any confusion :slight_smile:

Edit: Note that one would probably add some checks here and there, to ensure that there is actually anything to compute/get before making the calls.



Thank you very much for your Help! Sometimes its so easy but you dont see the misstake :see_no_evil:

Thank you! :wink:

1 Like