Insert place holder digit to be over written

Hi, I’m trying to renumber room numbers. However I need a 0 place holder that will be over written when the number becomes greater then 2 digits.

At the moment Im getting

A11, A12… A19, A110, A111

But would like to achieve

A101, A102… A109, A110, A111

Thanks for any help!

Hi mate! Hope this can help you (and as far as I know, you cannot do it in Revit this time, hahaha)

# The inputs to this node will be stored as a list in the IN variables.
lists = IN[0]
prefix = IN[1]

# Place your code below this line
numbers = []
i = 0
for list in lists:
	aux = []
	for number in list:
		nString = str(number)
		if len(nString) < 2:
			aux.append(prefix[i] + "0" + nString)
			aux.append(prefix[i] + nString)
	i += 1

# Assign your output to the OUT variable.
OUT = numbers
  1. Convert the string to a number.
  2. String.PadLeft to add the 0’s as needed.
  3. Resume as you were.

If you’d prefer to keep the number of nodes down this is the code block version:


haha to kind! thanks man

1 Like