If i have a list with multiple sublists, and each sublist has the same values. I’d like to increase a specific # in in all those sublists by 1 for each new sublist.
So in the picture, in the first sublist i’d want it to stay the same, but for each new sublist i’d want to increase the first number in the value by 1. so in sublist 1 it would change to M211, m211.1, m211.2…
If there was a third sublist i’d want it to increase to M311, M311.1 and so on
Not having much luck googling, not sure if there’s a specific way to describe what i’m trying to do.
Thanks in advance for any help! Would like to be able to do it with OOTB dynamo nodes if possible.
First up: you don’t have numbers, but strings. This is an important differentiation as we can’t do math with strings, so any attempt to just get the value and add one will fail. They do offer one benefit though, in that we can use a String.Replace node to do a lot of the work for us.
Start by counting the number of sub lists you have (List.Count), and build a range from 1 to that value (Range node or
1..n in a code block).
Next append the M prefix to the front of the list with an addition node.
Then use a String.Replace with the input string being the original sublists set to @L2, the value set to “M1”, and the replace with set to the result of the merged M and range @L1.
It’s not letting me add the M to each value in the range? I tried all the levels and lacing for the Add node.
AH i didn’t have quotations in the code block! Got it to work. Thank you!