Getting Items in Nested loop

Hello everyone, I would like to know if it’s possible to get the Points inside of the list in level 2, what I am trying to do, to get the whole points in list 0 and list 1 to make a line from that points,
very appreciated for help

Input 0 has 7 total points.
Input 1 has 2 vectors.
Input 2 has 2 lengths.

Are you trying to draw 2 lines? 7 lines? 14 lines? 28 lines?

I’m guessing (which means that your computer is REALLY guessing), that you want 7 lines, lacing the first distance and first vector with all of the points in the first sublist, and the second vector and second distance with all of the points in the second sublist. If not, I guess ignore everything else I am saying here.

Since you have nested lists at various lengths, you made things a bit harder on yourself moving to python right off the bat, but you may have a valid reason for this. If not, maybe stick with the out of the box method?

image

Note this even keeps the original list levels, which could be handy.

But you did seem to want to do this in python, and while I am not a Python expert I’m going to do my best to break that down as well. There may be an easier way to do this using a zip function, but again I’m not a Python expert so I don’t know.

Since you have a nested list, you need to iterate over the THAT list before you iterate over the points in the list. Otherwise you’re just drawing two points in the end as you’ve only got two lengths to append to your counter i. So, the first for statement should be for ListOfPoints in ListOfListsOfPoints

#For the list of points in the List Of Lists Of Points perform all of the stuff offset below.
for ListOfPoints in ListOfListsOfPoints :
#Get the vector at the counter index.
Vector = Vectors[i]
#Get the distance at the counter index.
Distance = Distances[i]
#Add one to the counter index and set the counter index to the resulting value (so if you had counter value 0 the counter value becomes 1, 1 becomes 2, and so on).
i += 1
#For each Point in the List Of Points perform all of the stuff offset below.
for Point in ListOfPoints :
#Append to the output list a Line starting from the point, moving along the vector we pulled in the prior statement, and continuing for the distance we pulled in the prior statement.
Output.append ( Line.ByStartPointDirectionLength ( Point, Vector, Distance ) )

With the rest of the code, it looks like this:

Hope it helps. :slight_smile:

2 Likes

Hey Jacob , what i am trying to do is , i am taking one direction and one length of the width edge in each room and to draw it at every point at the room ,as the example above one room should hhave 4 line and the other one 3 lines , and getting all the lines in room 1 in a list and second one as well .

you are right , it seems i am making it more complicated, I tried your soultion without the python and it works perfectly excatly as i wanted . thanks jacob you are the best

1 Like

Glad to have helped. :slight_smile:

it worked perfectly for Curve Division , but for line by segement couldnt go through the whole lines of the room , have you any idea about this ?

i tried it to do it in that way but still stuck in the part of applying this formula inside of BlockCode to the Width Curve by segment ?
python%20

Share the full dyn and whatever other files I will need to run it, as I don’t have a clue how to rebuild your list structure, or the time to recreate your work thus far.

sorry to bother it worked it was a level issue, my mistake , thanks jacob again it was mucher easier to do it in your way

1 Like

Glad it worked out.

Typically lacing and list levels will resolve such issues but you have to try them all, and there are many.

it did actually , just wanted to learn more python by replacing these nodes with python script , but easy way its the better way

That’s not always the case, so learning some of the basics (say by reverse engineering the code I posted above) is likely a good idea for your personal development. :slight_smile: