Find which lines are parallel

revit
dynamo

#1

Hi,

I am tring to create a script that will generate an aligned dimension between parallel lines from within a family. What i want to do first is to find out which of these 5 lines are parallel to each other. How would you go about on this?


#2

Try to group them by their vectors using Line.Direction ?


#3

Great! Line.Direction does it! Now, how would you group them?


#4

link your Element.Geometry node to the first input of GroupByFunction (“list”) and the Line.Direction node to the second (“func”). Dont link nothing to the Line.Direction node input, so it works as a function.

In this image I can see that you Element.Geometry node’s lists are at Level3, so maybe you need to use levels on GroupByFunction (click on the arrow at the “list” input and select L2)


#5

It might happend that due to a floating point error, two exact same vector are not grouped together.
Also, two lines can be paralled but their vectors opposite, so they will as well be grouped as different elements.

One option is to group them by the rounded sum of the absolute value of their vector X, Y and Z components.


groupingParallelLines.dyn (15.4 KB)


#6

Would that work if you had lines in the shape of a square? Since adjacent lines should have the same value but not parallel.


#7

I am now trying to group the vectors by dividing Vector.X / Vector.Y, and using rounded value of 2 decimals.
Only I do not know how the GroupByFunction works :confused:
I have the feeling this is the node i need but do not know how to set it up.
EDIT: also thinking about List.Map or GroupByKey, but I dont understand how these work.


#8

func input on GroupByFunction only accepts OOTB nodes, but not Code Blocks.
Try using GroupByKey as on my example instead, being the keys input the result of you code block.


#9

X, Y and Z components are from the line direction (vector), so they will be different from adjacent lines as long as they are not collinear.

It is true that adjacent lines will have coincident start/end point, but this doesn’t have any effect on the grouping.


#10

Thanks for your suggestions @alvpickmans. I tried it but got stuck at line length being also taken into account. So in the end there was no group bigger than 1.

I fixed a workaround. Now I have the groups of parallel lines. Still would like to know how to do this using List.Map or GroupByKey or GroupByFunction… I just dont get these nodes.




#11

You’re absolutely right, my bad.
Considering this, let’s change the “keys” to be the vector’s angle with the X axis, as image below.
Again, floating point error needs to be solved by rounding the angles obtained.

Apologies for the wrong method before.


#12

Thank you @alvpickmans! I got it.

I’ve created a new topic for the next step of my goal: creating the shortest parallel lines between these parallel lines. If your interested, please have a look here:


#13

That can be handled by normalizing the vector using Vector.Normalized

Not wrong :slight_smile:
However, you might need to also group together lines that are parallel, but with their direction reversed

See if this helps …
GroupParallel.dyn (17.5 KB)


#14

Hi @Vikram_Subbaiah, I thought about it but following the method I showed earlier (sum of vector’s components as comparison keys), using normalised vectors ends up grouping together any lines parallel to X or Y axis. I didn’t thought about creating a new vector though :slight_smile:

Using the “angle with X axis” method, setting an if statement can do the trick to only return angles between 0-180


Using Dynamo to Identify non parallel walls
#15

Hello @Vikram_Subbaiah,
i got your GroupParallel Dynamo Script. i’m able to group the lines which are parallel.
Firstly thank you for sharing the script.

I want to group the lines which are closer and equal in length.

i’m attaching the image so that you can understand what i’m exactly willing to do.

I need you help

Thank you in Advance.

Regards,
Rathnakar.


#16

Please start a new topic and show where you get stuck


#17

hello @salvatoredragotta

go with link…where i created the post and posted what i have done.

Thank you.

Regards