i would like to ask for help with creating multiline string from nested list. In the image below i manage to create list with layers of compound elements. The list contains material and its thickness. I want to create from those items multiline parameter and write it into shared type parameter.
After a lot of searching and experiments i could manage to do it so.
Any idea how to continue? My idea is to manage to create one dimensional list with combined strings with newline element between those values and than use it to set parameter by value.
Thank you for any help.
You could try to implement it by using a python script.
text = IN newText =  #add newline to the string for t in text[:-1]: newText.append(t+'\n') #add last line without newline newText.append(text[-1]) OUT = ''.join(map(str, newText))
Python Nodes Basics
@Adam_Huleja, use the special character “\n” as a separater, like this:
This way you’ll break down the string to be used in multiline text parameter. There’s a bug with multiline text though, when writing it with API - if you try to edit this text afterwards, you’ll get the single string without breaks.
Nested list to multiline text parameter
Hi and thank you for your response.
Right now iam trying to dive more into python. I am still beginner.
But the problem is still the same. I can manage to join items in one list with builtin nodes. The problem i have is, that i want to combine items in those nested list, but still keeping the upper level list structure. And there is also one condition, that every element can have different count of layers. I cant figure out how to “disassemble” that 2d list into those 1d lists, do the combining of items and store it into final 1d list.
Yeah, i thought about that character. Didn’t managed to get the list items combining to try, if Revit will take it correctly, yet:slight_smile:
Still, thank you for your response.
if you have a 2D list then implement this code
text2D = IN newText =  #add newline to the string for text1D in text2D[:-1]: for text in text1D: newText.append(text + '\n') #add last line without newline for text1D in text2D[-1:]: for idx, text in enumerate(text1D): if len(text1D)-1 > idx: newText.append(text + '\n') else: newText.append(text) OUT = ''.join(map(str, newText))
Home2.dyn (3.1 KB)
Once again thank you:) but this still gives me result of one string with all of the layers from all of the element types. And what i need is to get a list of strings with same number of items as number of elements (i want to combine only 2nd level of items together, while keeping the 1st level hierarchy of the original list). This is exactly the circle, in which i am whole day Every approach leads me to only one string with all the layers or some errors
Home3.dyn (3.2 KB)
text2D = IN newText =  for text1D in text2D: t =  for idx, text in enumerate(text1D): if len(text1D)-1 > idx: #add newline to the string t.append(text + '\n') else: #add last line without newline t.append(text) newText.append(''.join(map(str, t))) OUT = newText
Really?? I swear, that i have tried the String.Join node. Maybe i didnt have brain capacity to solve such a trivial problem.
Thank you and sorry for such a lame problem.
Thank you all:)
Oooh, i see, i didnt use the List.First node before and that was the missing part, which i overlooked.