Renaming Revit Material Names

I’ve searched as much as I could to no avail on how to just rename the Material Name in Revit. I’m in 2018 using Dynamo v1.3.3. Is it easier in v2.0? If someone can either point me to a page showing the details to do so & or provide a Node/Script/Graph assisting me in completing my script would be much appreciated.
Here is the Script I’d like to add the capability to. So I’m wanting to Export it to Excel, then modify a few other accessible properties & Import the update Excel file. Eventually I’ll separate the export/import functions for final use.
Edit Material Name & Data.dyn (43.1 KB)

2 Likes

MATERIAL_NAME is a valid parameter? Try with “Name”

1 Like

This should work;

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

Mat=UnwrapElement(IN[0])

if isinstance (Mat, list):
	Materials=Mat
else:
	Materials=[Mat]
	
if isinstance (IN[1], list):
	NewNames=IN[1]
else:
	NewNames=[IN[1]]

TransactionManager.Instance.EnsureInTransaction(doc)

OUT=[]

for mat,name in zip(Materials,NewNames):
	mat.Name=name
	OUT.append(mat)

TransactionManager.Instance.TransactionTaskDone()
1 Like

So I can only rename “per instance” (one-by-one)? I’am wanting to rename from the updated Excel file. Like below image is my ideal setup…


This script is for my project teams BIM Mgmt processes to standardized bastardized Material Names/Properties. Am I up the creek on wanting to do it from a list (renaming ‘material names’)?

Here is the Warning I’m getting…
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 30, in
AttributeError: ‘List[object]’ object has no attribute ‘Name’

Found this reference…
http://dynamobim.org/forums/topic/change-material-names/

I’ve found my solution…
https://www.revitforum.org/dynamo-bim/29758-renaming-materials-only-working-some-materials.html


Here is my sample above. So on my export & just create a new column with just the New Names being filled in.

4 Likes

Revit 2023, Dynamo 2.16.2

I have built a simple script to add prefixes to materials. But I am getting errors. Tried two variants, but both times unsuccessful.
Can you tell me what the problem is?

Thanks!

You are setting the “Name” for Materials, but do you know if “Name” is the correct description of the parameter?