Hi All, I’ve been using Dynamo now for about 2 weeks with good success. However, I’ve run across something that has stumped me. I’m trying to take items from a list and combine them into a string, which seems simple enough, but has proved difficult: I would like to take each equipment tag from a list and combine it into a string separated with “,” and place an “&” before the last one. So in the example below it would read “VCB-3, VCB-4, & VCB-5”. I’m assuming this will require a python script, but my computer programming is quite limited.
Any suggestions are greatly appreciated.
Thanks,
Dan
I am new to Dynamo too, so probably someone would have a better solution for this.
Hi Dan,
You should be able to get what you want with a few list- and string- nodes as shown below.
List.DropLast is from Dimitar’s SpringNodes package, but there are probably ways of doing the same thing with the built-in nodes.
Note the space characters included in the input strings (", " rather than “,”) if you want spaces in the output string.
Kind regards,
David
Hey, three different methods in two minutes: Fantastic!!
Yes, as Gustavo shows, List.DropItems with -1 as input does the same thing as List.DropLast, and it’s a built-in node.
Kind regards,
David
Thank you all for your responses. Great stuff! I ended up coming up with something, but I think your solutions will work better, and be more efficient:
If I knew python scripting a bit better I’m sure I could find a way to automate it a bit better. Thanks again for your help! Dan
Yes, I’ve got a few list management nodes that are just wrappers around the built in nodes. They’re there for when I’m too lazy to place two nodes instead of one
List.Split is another one:
Taking a leaf out of some of the earlier responses
Or in pure Python, just for fun.
Using a couple of Python’s string methods: https://docs.python.org/2/library/stdtypes.html#string-methods
1 Like