How to join strings together from different lists?

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


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

still don’t get it…:frowning:

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

how to join index [0] from each list?

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…

@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 ‘‘’

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

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

2 Likes

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

This one works!:grinning:

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

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.

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

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.

Have very big difficulty understanding List@Level in Dynamo :smile:

This is not an issue of list levels. As I mentioned in my previous post, those nodes do not handle list reduction. They must all use the same list structure, defined by the first input. You’ll just have to split your graph and use one node for the first two inputs and a second node for the last one. (Which you’ll also need to convert to strings.)

Thanks for the kind advice. It worked unexpected.
Intuitionally, we use “+” for numbers, “&” for strings.

This is how Dynamo works. The + node can combine numbers and strings. The functionality varies depending on the object types used. String.Concat is specifically for strings (hence the string input) and fails if you provide a number.

1 Like