How to get single "event" from intersections

Is there a way to get a single item out of the:

<Rhino.Geometry.Intersect.CurveIntersections object at 0x0000000000000086 [Rhino.Geometry.Intersect.CurveIntersections]>

without the need to loop through all?


print insect_event_01.Item(1)

results in this error:

Should just work with:


Not on a PC right now

No, this is the python way and the first thing I tried :slight_smile:

This is the resulting error:

You can use CurveIntersections.Item Property to get the intersection event data at the given index.

If you get this error the size of your collection is 1 meaning you can only index up to 0

If my_int_events.Count > 1:
    print my_int_events[1]

no, I get this erorr with 0

@Mahdiyar, isn’t that what I am doing in my original post?

What is the .Count property of your collection?


but this indexer has two items inside which I cannot get individually.

This is what I want.

So in your last iteration of the loop your collection is empty. If you check for empty before indexing inside you won’t get an error.

1 Like

Just replace 1 with 0

If you can’t get it to work I can send you a sample thus evening

the only thing I get out of that is an integer, and I want the point. Which is the intersection between two curves.

Something is wrong with that .Item property

OK I thought you were trying to get the events out of the collection.

Now I get it.

You can use the properties

  • .ParameterA
  • .ParameterB
  • .PointA
  • .PointA

To get out points and paremeters of a single intersection event

yep, but these events are apparently intersection results. according to RhinoCommon dictionary

I can use .PointA, but I have to loop to get it I can’t just pick one out of the insect_event

import System
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import time

tol = sc.doc.ModelAbsoluteTolerance

def TST():
    curves_ids = rs.GetObjects("get curves: ",rs.filter.curve)
    if curves_ids == None: return
    curves = [rs.coercecurve(id) for id in curves_ids if id is not None]
    for i in range(-1,len(curves)-1):
        #print curves[i]
        curve_0 = curves[i-1]
        curve_1 = curves[i]
        curve_2 = curves[i+1]
        pt_01 = None
        pt_12 = None
        if not curve_0 or not curve_1 or not curve_2: return
        # Calculate the intersection
        intersection_tolerance = tol
        overlap_tolerance = 0.0
        insect_event_01 = Rhino.Geometry.Intersect.Intersection.CurveCurve(curve_0, curve_1, intersection_tolerance, overlap_tolerance)
        insect_event_12 = Rhino.Geometry.Intersect.Intersection.CurveCurve(curve_1, curve_2, intersection_tolerance, overlap_tolerance)
        pt_lst = []
        #print insect_event_01
        #pt_01 = Rhino.Geometry.Point3d(insect01.Item(0).PointA)
        #pt_12 = Rhino.Geometry.Point3d(insect12.Item(0).PointA)
        print insect_event_01.Count
        if insect_event_01.Count > 1:
            #print insect_event_01.Item(0)
            print insect_event_01[1]
        for event in insect_event_01:
            print event.PointA2
            print event.PointB2

Question is why do I have to do that for event in insect_event: loop?

I want to just take the first event in insect_event:
like so:
insect_event[0].PointA but I can’t

Another mind blowing thing:

if I want to add the resulting point into a list I get an error.

if I do this:

for event in insect_event_01:

I get an error. Why?!

I don’t get an error, actually but the list is empty.

PointA2 only works when there is an overlap

I can take a look in the evening

oh shit. I’m wrong :smiley:

For this I’m wrong as well :smiley: the last list is empty because the insect_event_01.Count = 0

Back to the initial topic. This is still unanswered. :slight_smile: