Replacing Material Apearance Asset in the Revit API

Hi all,
I am am new to computational BIM and I am trying to solve this problem in revit:

I am particularly interested in the visual material API in my work and I was wondering if there is a method to replace the aprearance asset of a specific material with an apearance asset of already existed materials.
I do lots of IFC geometry import and normaly that geometry comes with its material and the ideal way to change the geometry material is to replace its apearance asset.
If there is a possibility in the Revit API to do that without going into the asset properties and change them would be great !.

This will exactly function like the botton in the apearance UI in the material window.

Any easier solution through customized tools in Dynamo is welcomed

Looking forward for you answers !.


Hi @cadrobots ,
Materials have a get,set AppearanceAssetId property. So yes it is possible!


Thanks Mostafa. I am checking it right now.

There is an interesting talk about it by the way !.
Check it out :

1 Like

Inetersting indeed! Let us know what you come up with or if you need help with the process :slight_smile:
good luck!

I have retrived the materialAssetID of Cherry material and it returned to me the Elementid of the apearance asset of the mentioned material. Then I have tried to set a value to one of the materialAssetIDs of my element materials like this :
Material.materialAssetID.setValue(…The materialAssetId of Cherry material…).

the error is Ican’t change the value of an element id. This is the Python code I have written for that:

import clr
import math
from Autodesk.Revit.DB import*

#set the active Revit application and document
app = revit.Application
doc = revit.ActiveUIDocument.Document

#define a transaction variable and describe the transaction
t = Transaction(doc, 'This is mz new transaction')

#start a transaction in the Revit database

#Add Code

#Get the apearance id of the intended material
#get all the elements ids in the document
collector = FilteredElementCollector( doc ).OfClass( Material )

materialsEnum = collector.ToElements()


IntendedMaApName = 'Cherry'
MatApAsId = 0
for i in materialsEnum:
if i.Name == 'Cherry':
#get the apearance Id of the intended material
MatApAsId = i.AppearanceAssetId

#get the materials of the selected element in the Revit UI
selection = uidoc.Selection;
selectedIds = uidoc.Selection.GetElementIds();
#get sellected Element
SellectedElement = doc.GetElement(selectedIds[0])
#get all the ids of the materials assigned to that element
EleMatIds = Element.GetMaterialIds(SellectedElement, False)

#get the material of the materialid

SellectedMaterial = doc.GetElement(EleMatIds[1])

#get The apearance id of the selected material element
appearanceId = SellectedMaterial.AppearanceAssetId

#Apearance element of the selected material element
appearanceElem = doc.GetElement(appearanceId)

#Changing ApearanceAssetId of the sellected material into the Id of Cherry material

#appearanceId = MatApAsId

#commit the transaction


I am using the Python shell in revit for the debugging !.

If you can help me to understand how I can change the value of this ElementId so the imported material will have the same apearance of the cherry material would be really helpful !.

Cheers, Ghaith

you should try :

material.MaterialSetId = (your material asset id)

I couldn’t find this option"MaterialSetId" in the material class !.

I am using Revit 2018 !

Sorry I meant materia.MaterialAssetId :sweat_smile: !

Hi Mostafa,
Thank you for your prompt feedback !
There is no such an attribute to the material class. I feel like we should go in a different direction.

Hi again,
It workd finally by assigning the value using the normal way. I thought both ids are integers.

Just simply :
SellectedMaterial.AppearanceAssetId = MatApAsId

Thanks for your ideas. looking forward for next interesting discussions.


Glad you got it to work! and yes… AppearenceAssetId like shown in my first screenshot.

Thanks !. I am trying to extract the color value

Particularly something more like this value : RGB 0 127 0

I am using the Color.getvalue() method, but I always get an error message that the Color object doesn’t have this attribute getvalue.

I thought this information is a char array which I can get from option. but I get always the same errors. Any ideas ?

Are you after this ?

You can get RGB values of Revit.DB.Color elements like this :

1 Like

Thanks alot !. This makes it so obviouse.The unrap method is something you have programmed in inother codeblock ?
Because I couldn’t see it in the documentation !.
But I can get the color values like this Material.Color.Green for example. which is fine. It is wierd that I can’t see the red, green, blue in the dropdown menue for the color object options.