How to join strings together from different lists?

dynamo

#1

Having some problems understanding why the String.Join is not working as intended.
My goal is to have a lists like

[0] Level 0 - WRK - ZONE A
[1] Level 0 - WRK - ZONE B
[2] …

[0] Level 1 - WRK - ZONE A
[1] Level 2 - WRK - ZONE B



#2

string1 + " - " + string2 + " - " + string3;


#3

still don’t get it…:frowning:


#4

why is it sequencing all Level 0 - Level 0 - …
and not the WRK - WRK - …?


#5

how to join index [0] from each list?


#6

you should use levels on your String.Join node.

or you can just use a Python Script node (I don’t know what this WBK means so I just called them “items”):
pyth.txt (417 Bytes)

I think it might work…


#7

@ricardoperucci,

Tried using Levels but it did not work either

I tried the Python but I got this error (I do not know enough to debug it myself)

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
unexpected token ‘‘’


#8

Check my post again after the corrections I’ve made, so you can see the python structure correctly.

At the second line, ‘ProtoGeometry’ should be as a string, with this symbol ’ before and after it. It is changed when written here


#9

Sorry, forgot the list level. Put this in a code block:
string1 + " - " + string2 + " - " + string3<1>;


#10

It may have to do with the levels for the lists.
I get this when I try List.Join


#11

This one works!:grinning:


#12

@Nick_Boyts
Could you just clarify on what I was doing wrong so that I can learn in the process?
Thank you
:slight_smile:


#13

The way I understood it was that String.Join is just a concatenation with a given separator. It takes a list of strings and joins them into a single string. It just happens to let you do this with multiple lists (multiple inputs), it doesn’t actually join the lists together.


#14

Thank you @Nick_Boyts
Bu why then it does not concatenate all WRK-WRK-WRK-WRK?


#15

I believe that’s because of the list structure. I’m not sure if list levels actually work on String.Join or not. I’ve never tried.
But it seems like it follows a singular list structure which means it’s joining your level 2 lists in this case, which happens to be singletons for the WRK list.

Edit: After some (very) brief testing, it looks like the String.Join node uses the list structure of the first input. List levels seems to have no affect.