Intersection between a line and a geometry

Hello,

Here’s my goal : i would like to, in the active view (a plan view) ask the user to draw a line and get the intersection between this line and all the elements in the active view.

For exemple, if the user has drawn this red line it should give the coordinates of the green points.
image

Here’s the start of the program :


First of all, the node “pick points on workplane” gives inconcistent units (z = 63590 as the node “Element.getlocation” gives z = 6359mm).
Obviously, due to this units problem, the node “Geometry.intersect” doesn’t give anything.
But i also tried to match a manual point with one of the geometries and it doesn’t work either (empty list out).

Thanks for your help ! :smiley:

You’ve more or less identified the first problem: you’re drawing a 2D line in 3D space. You need to convert your line to a plane/surface so that it actually intersects the entire depth of the view. The second problem is similar in that GetLocation also returns a 2D geometry in 3D space. You need to use the actual geometry (maybe even specifically within the view) to get the actual intersection with the “line” that’s been drawn.

1 Like

Thanks for your answer.

I’ve changed a little bit my approach : the user may now draw his line in revit before the execution of the dynamo, so i’am just using the “select model element” node to get the geometry of it.

Because of what you told about the 2D-3D conflict, i have now a line drawn which has not the same z as the elements.

I imagined 2 solutions to solve this problem but i didn’t find how to apply them :
_Remove the z coordinate so i can manipulate the objects only in x and y (i didn’t find any node to do that)
_Convert the z coordinate of the elements into the z coordinate of the drawn line. I could compare, for each element geometry, the difference between it’s z and the drawn line z so i make a translation with this difference, but how can i manipulate their z coordinate as numbers ?

Thanks again for your help.

I figured it out with this and it’s working ! :slight_smile:

1 Like

You’re still likely to have issues with actual geometry since you’re using the element location still. In your original example you mentioned getting the coordinates of the (4) green points. Your current workflow will only return 2 points. The location geometry of a wall is a line, not the representative geometry. This is an even bigger issue with point based elements as an entire rooftop unit would only show as a single point and would have to perfect align with the line to intersect.

hello,
here is an approach to make the cut surface from your line


Cordially
christian.stan