Change type name with python


#1

Hi

Is it possible in any way to change the type name in Revit with Dynamo? Maybe with Python?


Dynamo Can't write string to "Text Name" field of Revit Text
#2

like this?
RenameElement.dyn (7.8 KB)

# Common Language Runtime module
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')

# Revit and Dynamo module
from Autodesk.Revit.DB import FilteredElementCollector, Family
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# argument assigned the IN port
search = IN[0]
rename = IN[1]

# core data processing
type_name = []
collector = FilteredElementCollector(doc).OfClass(Family)
TransactionManager.Instance.EnsureInTransaction(doc)
for element in collector.ToElements():
    for idx, searched in enumerate(search):
        if searched == element.Name:
            element.Name = rename[idx]
            type_name.append(element.Name)
TransactionManager.Instance.ForceCloseTransaction()

# return assigned the OUT port
OUT = type_name

#3

Yes! Thank you…