Create custom list to label things (B.01.01, B.01.02 ... B.02.01, B.02.02 etc)

Hey Folks, I’ve been finding solutions on these forums for my Grasshopper questions for quite a while now, but I seem to be stuck now, so I will post my first thread ever (aka, a long time)

I want to generate a list of 160 numbers to label sections I am generating in Grasshopper.
The list has to be as follows:
B.01.01
B.01.02
B.01.03
B.01.04
B.01.05
B.02.01
B.02.02

B.02.05
B.03.01

untill we get at B.32.05, which will be the 160th and last entry of the list.
So it will always start with B., followed by first coordinate, (1-32), followed by a second coordinate (1-5)
This will be the input for a tag-component

I feel like there should be a simple way to make lists like this, but have not been able to find it. Could you help me out?

Hello,

This is quite easy to do with a Python component. Here is one way:

a = list()                       # default output name, set up as a list
for num1 in range(1,33):         # 1 included, 33 excluded
  num1 = str(num1).zfill(2)      # convert to string, add leading zero

  for num2 in range(1,6):
    num2 = str(num2).zfill(2)

    label = 'B.'+num1+'.'+num2
    a.append(label)              # add label to the end of the list

Format List.gh (7.6 KB)

edit

you actually don’t need the long list component

image

you don’t need the repeat data component, grafting the input is enough.

Canvas%20at%2014%3B12%3B25

1 Like

Or as a python 1-liner, for the fun:

a = ["B.{:02d}.{:02d}".format(a,b) for a in range(1,33) for b in range(1,6)]
2 Likes

Thank you for the help guys, I’m completely unfamiliar with Python, so I think I will opt for the Format-component, which I did not know untill now.