Rename Family Types Python Script

Any idea how to change input as a list? Now it only takes 1 item.

You have to loop your in[0] in order to do it for multiple items.
Like so.

import clr
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

elements = UnwrapElement(IN[0])
newname = IN[1]

output = []
counter = 0
t1 = "Renamed element "
t2 = " to "
TransactionManager.Instance.EnsureInTransaction(doc)
for element in elements:
	org = element.Name
	new = element.Symbol.Name = newname[counter]
	result = t1+org+t2+new
	output.append(result)
	counter = counter + 1
TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = output
1 Like

Thank you! Works like a charm!

@snnybsch
Trying out.
but didnt work :slightly_frowning_face:

Hi Guys

I am trying to assign different names (in “newname”) to each element in elements with the code below. Unfortunately, only the last name in “newname” is being assigned to all elements. Seems like I am not able to iterate through one element at a time and assign specific names to them.

TransactionManager.Instance.EnsureInTransaction(doc)
for i, element in enumerate(elements):
	element.Symbol.Name = newname[i]
TransactionManager.Instance.TransactionTaskDone()

Any help is very welcome.

Thanks for your time.