Record all the intersection of a line through a set of different objects

Hi everyone,

I am trying to wonk out a problem which require a set of data in XML format. Basically, I need to the measurement of a line (from a point) to each object (all solid / enclose object) it is intersecting. There will be a set of lines radiating from the origin. And say in the end I can get something like:

“object_layer, xi,yi,zi, xj,yj,zj”

until the line doesn’t interacting anything.

The objects will be given as an imported file like STP or something that’s not native to Rhino.

So far I am able to generated the geometry of the lines will be radiating from. and get all the intersections. But couldn’t figure out how to get info about which intersection is come from which line on which object. and not sure what would be best way to output those data to a XML format I am after.

I mean I can manually measure for each segment, and input the object layers. this would be work on the lower line counts, but in some cases, the line counts can go up to few thousands, and doing it manually would be pretty silly. LOL.

Wondering if anyone might have a good strategy to go about this problem. I don’t mind to do some scripting, but it would be ideal if there are grasshopper only solutions.

Thank you so much for all the helps in advance!!!

I think it would be more clear if you drop a simplified version of your model :slight_smile:
first thoughts; if you have intersection points, you can create lines (origin → intersection) and read each length

this is a very simplified scenario, but I think the output of the BLX component (and its data tree structure) are giving you all the info you might need (19.4 KB)

each element in the data-tree is like:
{index of line ; index of intersected solid}
Point3d where intersection happened

the order in which -for a given line- the intersections happen is not sorted by distance, but just follows the initial order of the solids (recalls their indexes)

but I think this it might be a starting point :slight_smile:

for each intersection event you can calculate the distance between the line starting point and each of its intersection points, and sort them ascending synchronously with the intersected solid indexes
this way you will get:
a) index of line we are talking about
b) index of solids that line hits (sorted from the closest to the farthest)
c) intersection point between line at index a) and solid at index b)
d) distance measured along line index a), from “a) starting point” to “point c)” (19.2 KB)

Thank you so much for the reply and support!

I am trying out all the stragolgy being suggested, in the meantime. Here is an example of what I am doing.

There are few example objects on different layer. and I got some radiation line coming from the origin. and these line intersect the objects at different point (s)
What I need to do is make a measurement of the segment every time a ray passing through an object, and record what the object is, for every single ray. As well as documenting all the segment per line like:

line 00: Object A - 52mm (xi,yi,zi,xj,yj,zj), Object B - 4mm (xi,yi,zi,xj,yj,zj),
line 01: Object B - 43 (xi,yi,zi,xj,yj,zj), Object D - 25mm (xi,yi,zi,xj,yj,zj),

The actual formatting would be in XML, this is just try to get the idea across.

*note: if the origin happen to be inside an object, than it should make the distance from of origin to the first intersection of that object. But that might not be the case every time. there will be cases where the origin are just in the middle of empty space.

And once again, thank you so much for all the suggestions!!

Object A → intersected object
52mm → distance from ray origin to first intersection point between ray and object (?)
(xi,yi,zi,xj,yj,zj) → the first set xyz(i) are the intersection point “entry point” of the ray (?) and the second set xyz(j) are the exit point of the ray (?)

in case of an object like this, with multiple walls that belong to the same volume, how do you want the definition to behave?

Yes, those are the correct assumption.

I guess the first object is a bit tricky sense there are three possibilities on where the origin might be.

1.) The origin is inside of an object > resulting the first intersection of all the rays will be where the rays exist the object. and they wouldn’t have an enter and exit pairs before the ray hit and second object.

2.) The origin is outside of an object > resulting all the ray will have an enter and exist pairs for all the object the rays intersect.

3.) The origin is right at surface of an object > resulting some rays have an enter and exist pairs, and some don’t.

But I think sense all the object will be a “solid” or “fully enclose” every other one except for the first will have at least one enter and exist pairs.

And in case, the ray hit the same object twice or more, I was to record every encounters / intersection, because to the ray, it don’t really matter whether or not it is the same object. and I can see that’s where kind of a little tricky, and I can’t figure out what would be the best way to handle case like this. But really, every objects under the layer can really be consider as the same object. as each layer is where the properties of the object under will be define.

So in that case you show, it would be something like this:

O ----------- *(Obj A)52mm -------------------------- (Obj B) 6mm ---------(Obj B) 6mm ---------->

Or when expended

O -----------(Obj A XYZ) = 52mm ----------------------(Obj B XYZ) ---- (Obj B XYZ) = 6mm ---------(Obj B XYZ) ---- *(Obj B XYZ) = 6mm--------------------->

or you can see it like this

Obj A = 52mm
Space = Xmm
Obj B = 6mm
Space = Ymm
Obj B = 6mm

The space will be ignored for my final purpose, but don’t mind to record it for completeness, in case it comes in handy later.

This is not the exact format but that’s kind of the concept, basically recording the entire ray until it no long hits anything. It would be ideal to record which object is which, but like I said, every object under the same layer can be see as the same object for my purpose.

Once again thank you so much for helping me out with this. I have play with grosshopper for a while, and I am slowly picking it back up. You guys are being very helpful!