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?
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?
Try to group them by their vectors using Line.Direction
?
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)
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.
Would that work if you had lines in the shape of a square? Since adjacent lines should have the same value but not parallel.
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
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.
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.
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.
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.
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.
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:
That can be handled by normalizing the vector using Vector.Normalized
Not wrong
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)
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
Using the âangle with X axisâ method, setting an if statement can do the trick to only return angles between 0-180
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.
Please start a new topic and show where you get stuck
hello @salvatoredragotta
go with linkâŚwhere i created the post and posted what i have done.
Thank you.
Regards