Hello there! So the other day I tried to use Export DWG node from GeniusLoci package, it works, the only problem is if 2 sheets have the same file name it just overwrites the first one. I have multiple sheets with the same names in my project and I just want them to be like xxx.dwg and xxx(2).dwg, so the task comes down to identifying identical names in list and marking them with (2), (3) and so on. I don’t even know if I can achieve it using dynamo nodes, but I think there must be some consistent solution in python. Maybe someone has a notion how to do that?
Could something like this work for your workflow? Just replace the “A” in the code block with the number one?
This is based off of @jostein_olsen’s work:
This is what I got:
2 Likes
If you prefer the python route, something like this would work:
increment names.dyn (5.1 KB)
def increment_names(names):
name_dict = {}
for name in names:
# If name is not used, yield name and add it to dict.
if name not in name_dict:
name_dict[name] = 0
yield name
# If name is used, increment its counter by 1 and yield
# modified name.
else:
name_dict[name] += 1
start = name[:-4] # Get name without extension
end = name[-4:] # Get extension
num = name_dict[name]
yield '{s} ({n}){e}'.format(s=start, e=end, n=num)
OUT = increment_names(IN[0])
5 Likes
Cool! It works