Add Keys to List

I would like to add keys to the list so that I have a Minimum of 6 keys per list every time. I have 6 parameters that I will be setting values to. Everything works as it should but I am trying to eliminate the Warnings that are generated by the List.GetItemAtIndex node. If list at least 6 keys I would no longer receive these warnings.


image

Maybe try adding a Count, to count the number of items from each list in the string from Object node. You will need to set the lacing of the Count node so it counts each level. Also, the count total will be 1 more than the last index value since the indexes start at zero. So you will need to subtract 1 from the count totals. Then feed that into your GetItemAtIndex.

Essentially I need to somehow combine the list like I would do with Code Block “A+B” the issue I have there is I cannot do longest lacing with this method. Unless there is something else that I need to know?

Example to the right is my end goal.

Probably a better way using python, but here is the long version, if I am understanding the results you are after.

Using the List.AddItemToEnd is the little tidbit that I need to accomplish my goal. My graph now runs with no errors which I was trying to accomplish and it filled my list as expected.

You can transpose then transpose again, then replace nulls with “”. This will only make them as long as the longest list though, so if your longest list is 5 but you’re trying to get them to 6 it won’t help. I suppose you could manipulate that by adding a list of blanks to the front and then remove that first blank list after the second transpose, but then it’s no longer just a couple of nodes.

If you’re making strings out the numbers anyway you could get funky and use string join/split with some PadRight in between.

Or Python:

lists = IN[0]
padLength = IN[1]
padChar = IN[2]
for l in lists:
    l += [padChar]*(padLength-len(l))
OUT = lists
1 Like