[Help please] How to use Branch number as Index for another list?

Hello all!

This is probably an extremely basic question, but I just can’t seem to figure it out. I have a model of many curves (a simplified version shown here);

One curve is then randomly selected.

I then find the intersection points between that one curve and all the other curves.

This gives me a tree with some branches containing points, others not (because they don’t intersect).

I need to then identify / select these curves that have intersected (i.e. branches in the tree that contain points). In other words, I need to use the Branch Indices of the (cleaned) data tree as indices for the original list of curves.

For the life of me, I just can’t figure it out, surely there is a way to just use these Branch numbers as integers and then use “List item”?

I know member index / item index would work but this seems really slow and inefficient.

Thanks in advanced guys!
Henry

5.gh (21.5 KB)

The last image shown there is the desired outcome.

Ideally I’m looking for the fastest/cleanest way to do this, because the actual model is very complex and involves iterating this exponentially, as it is analysing the spread of a disease (which grows exponentially).

Maybe a custom python component would be best?

Thanks again!

This could be one way…


5_re.gh (22.4 KB)

or this:

If you are looking for speed P is not the way to go.
Probably the best would be a compiled C# with parallel looping.
Also if it is just lines in your model a line line intersection should be faster than cruve curve.

Thanks Kim for helping me out so quickly! That’s actually interesting because I never knew about a “collision” component before, which I could use instead of the curve-curve intersection entirely!

So thank you!

Thanks a lot for your help, your method turned out to be the fastest, using tree statistics…etc so thanks a lot for that!

Ah unfortunately I can’t code in C# and I’m also not sure what compiling it is?

The only problem with that is that the lines are polylines, not line segments, I’ve tried exploding but it takes a lot longer than just using curve-curve intersection.

Thanks again for your help though!

maybe this helps:


20210508_IntersectLines.gh (13.9 KB)