Drawing lines with if statement?

hi, could someone help me,i only want lines to be drawn between two points if the distance between two points is 1. for now my script looks like this but i don’t know how to only let the lines with a distance of 1 to be drawn

Don’t think of this as an if statement. There’s really no “if… else…” logic here. We just need to find paired points or specific lines.

That being said, we need a little more information around how you’re comparing points for line length. Are you expecting all combinations of points that would result in a 1 unit length line or once a point is used is it no longer viable? If the latter is the case, do you need to optimize around total number of lines or should it be dependent on list order? How do you know that your list even contains one possible solution?

What exactly are you trying to do? Could you just draw lines to length from the beginning?

Both of your attempts are a good start. Creating the line is a good option since that’s the outcome you need. Now just check the length of each line and see if it’s 1. Then you can filter all the lines that pass your condition.

i basically want to create a maze, i want a line to be drawn for each point in the x and y direction but only if the next point has a distance of 1.

But bcs it would be more work (i think) to draw lines in the x and y direction (individually) i did the lacing in crossproduct so that i could filter the lines (with a vectorlength of 1) afterwards. (which i’m struggling with)

But the problem with using cross product (i think) is that there would be drawn a line twice between two points with a length of 1?

From your code block, set up two List.FilterByBoolMask nodes. One takes the start points as the list and the code block comparing the length as the mask. The other takes the end points and the same mask. Draw the lines by the two ‘in’ outputs.

1 Like

Make sure you deal with those nulls and use Curve.Length instead of Vector.Length.

You will have to deal with duplicates, but there are ways to handle that either before or after drawing the lines. I’d suggest looking for unique pairs after grouping start and end points (or indices).