I’ve managed to get a dynamo script set up that successfully adds a “0” to the front of all of the detail numbers for all views on sheets. I’ve posted it below. Now that I’ve accomplished that, I’ve run into some problems with filtering out views that I don’t want to add the “0” to. My project currently has details with single digit numbers (1,2,3), details where the zero has already been added manually (01,02,03), and details numbers 10 and higher (10,11,12…).
I only want to add the “0” to the single digits.
I think I get the idea that I have to boolean out the views with the existing 2 digit numbers, then run both the “Parameter Value” output and “Sheet Views” output through the same boolean.
I’m looking for the most efficient way to boolean out those two digit detail numbers… any ideas?
Here is my updated script using Vikram’s advice. Also, I realized that I wanted to exclude any views where the detail number is a letter, so I set up a boolean mask and ran both the parameter values and the views through the filter.
It pretty much works, but there is one problem - it doesn’t always work and sometimes I get an error on the "set element parameter " node that says “this parameter is read only”. Not sure what’s causing the problem, but I suspect it’s something about the transition from “parameter by name” to “parameter value”?
Can anyone look at this and see right away what the problem is?
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
def convert_numbers(numbers):
# Initialize an empty list to store the result
result = []
# Loop through each element in the input list
for item in numbers:
if isinstance(item, list):
# If the element is a list, call the function recursively
sublist_result = convert_numbers(item)
result.append(sublist_result)
else:
# If the element is not a list, convert it to a string with leading zeros
str_num = str(item).zfill(2)
result.append(str_num)
# Return the result
return result
# Input list of numbers
numbers = IN[0]
# Call the function to convert the numbers to strings with leading zeros
result = convert_numbers(numbers)
# Output the result
OUT = result