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?

Use element.setname instead of element.setparameterbyname. For whatever reason parameter says it’s read only value. I had this exact issue and element.setname fixed it

hi!

I’m trying as you advised, but can’t solve the problem anyway… I need to rename my library of materials… Ideally dependind by using elements (all Elements have their own coded name)

1 Like

Do you know the way to display materials according to the assigned element? The idea is to be able to rename the materials by inserting its category/discipline in the name string. An example:
Sanitary pipe diam.110

MEP_SAN_TuboDiam.100
MEP (general)
SAN (Category/Discipline)

Thanks!

Can you be a little more clear? As i don’t understand what exactly you want.

Would this be the material name in your example?
TuboDiam.100 is this a Family Name / Parameter?
Are the more categories and / or discplines?

I would like to insert, with three letters of the material code (name of the material), which category the material belongs to. In the example below: in yellow I mark all the elements belonging to the “mechanical team” category. The idea is that in the code of the material that is reflected it is apart
Example: Material name: MEP_(Category)_(name)

What you want can be done but, to be honest, i wouldn’t that.
What if you have a material for two disciplines. Then you have the same material twice
(in the material library). Also you have to duplicate a material when it doesn’t exist yet
for a discipline.

And can you be a little more clear about this :point_down:

image

If I have the same material for one category I’ll put “GEN” as general

the second I mean: the dynamo tab “category” is the same for “materials” or “elements”, so it is impossible to select a material of a category of phisical elements at the same time

A material is a material.
There is no such thing as a ‘material per category’ or i still misunderstand what you mean.

yes, I think you’re right… Thanks a lot for your time!

There is just a language barrier. No need to give up.

You can select Elements by category.

But for materials, they aren’t selectable because they are elements that don’t have geometry (similar to how Views are Elements but have no ‘geometry’)

However setting materials to the Category of Elements (lightning fixtures, MEP etc) isn’t something I would ever do for two reasons

  • Objects can share the same materials. So you will have a ton of duplicate materials this way
  • You will have to keep updating your material library

You can make a material schedule instead to see which element has which material. So you’ve already done that. You can just set a filter in the Schedule