# Create Materials with Appearance color value using GeniusLoci package

**URL:** <https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316>\
**Category:** Revit\
**Tags:** revit, dynamo, package\
**Created:** [February 19, 2019, 9:09am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316 "2019-02-19T09:09:15Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [February 19, 2019, 9:09am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/1 "2019-02-19T09:09:15Z")

</div>

Hi all,

I am trying to map colors as real materials in Revit so that I could render them.  
I have successfully created the materials as shown below with the Graphics color created but the Appearance asset color value doesn’t change. I tried a node from GeniusLoci package but it just gives me null values. I still have no knowledge of Python and can’t really understand the code inside the node T\_T. I hope somebody can assist. Thank you so much!!

_Created Materials with Graphics color but no color in Appearance asset tab_

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/d/edcfe17a32557c7b237991bd0dbf8b469ed5808e.png)

_Null values using Material Set Render Appearance color which is supposed to copy the Graphics color values to the Appearance Asset color:_

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/2/82384d0852f3e9e2f5adca04eef3ad45d97d83f7.png)

_Material Set Render Appearance color python code:_

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/e/4eaa3241505d44c9e6cdb9dd1f46e7b74dd768d1.png)

```
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

def tolist(obj):
    if hasattr(obj, ' __iter__'): return obj
    else: return [obj]

materials = tolist(UnwrapElement(IN[0]))

for mat in materials :
	appearanceAssetId = mat.AppearanceAssetId
	assetElem = doc.GetElement(appearanceAssetId)
	TransactionManager.Instance.EnsureInTransaction(doc)
	with Visual.AppearanceAssetEditScope(assetElem.Document) as editScope:
		editableAsset = editScope.Start(assetElem.Id)
		genericDiffuseProperty = editableAsset.FindByName("generic_diffuse")
		genericDiffuseProperty.SetValueAsColor(mat.Color)
		editScope.Commit(True)
	TransactionManager.Instance.TransactionTaskDone()

OUT = materials
```

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 19, 2019, 9:36am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/2 "2019-02-19T09:36:54Z")

</div>

Hello.

Can you try taking the Python code out of the custom node and put it into a python node and see if any errors show up?

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [February 19, 2019, 9:44am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/3 "2019-02-19T09:44:57Z")

</div>

Hi @archjahzzy,

You must add an appearance asset for each material before you change the color of the appearance asset or add a texture or a tint color.  
Use the `Material Create and Add AppearanceAssetElement` node.

 ![Create%20materials](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/b/db05710390bc30bcb4e2099a172aa213cd13d78a.png)

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [February 19, 2019, 10:29am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/4 "2019-02-19T10:29:29Z")

</div>

Hi @Alban_de_Chasteigner, thank you!

I am not sure why mine doesn’t work… do you have any idea? I sampled 4 items from the list because I have over a thousand materials:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/0/a06225ee0506089829bcddd570ea388d8537a2e5.png)

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 19, 2019, 10:30am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/5 "2019-02-19T10:30:26Z")

</div>

Can you try flattening the inputs and removing the list levels?

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [February 19, 2019, 10:31am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/6 "2019-02-19T10:31:03Z")

</div>

and here’s the flattened version:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/9/09ca1bd8e58bd8c01f2e06fa4701e04d2fe9b8da.png)

here’s a more complete graph:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/4/143c7a05c5fb45590721225d38e5838e4d2a5041.png)

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [February 19, 2019, 10:36am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/7 "2019-02-19T10:36:50Z")

</div>

Do you have a material called “Default” ?  
Are you working with Revit 2018.1 or later ?

 ![Appareance](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/9/a948e3ec6266d2d791df41380285a8beb49a52da.png)

If so, can you drop a sample file please ?

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [February 19, 2019, 10:45am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/8 "2019-02-19T10:45:49Z")

</div>

I am using 2018.3, and yes there is a material called “Default”… but the materials I’m creating have different names. I will send you the file.

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [February 19, 2019, 11:24am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/9 "2019-02-19T11:24:02Z")

</div>

Well, it works on my side on your purged file.

 ![materials](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/4/e454444a8e6c47763330529214217584b3b86ee1.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/2/92024cf2fd187b0b3d99440b5093cf9ed0dd69e7.png)

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [February 19, 2019, 5:55pm UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/10 "2019-02-19T17:55:04Z")

</div>

Hmm…  
Strange. Maybe it was just a bug? Anyways, thank you so much! I’ll try it again tomorrow. Hopefully it will work.

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [February 20, 2019, 4:26am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/11 "2019-02-20T04:26:50Z")

</div>

Hi all,

I guess the problem is in the computing power of my pc or it’s just buggy. It works when I split the material creation by batches of around 200 materials. 🙂 but gives null values when I run all of them.

But the node works after using the `Material Create and Add AppearanceAssetElement` node.

Thanks all!

---

<div class="post-metadata">

**Author:** ![EmirHM](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@EmirHM](https://forum.dynamobim.com/u/EmirHM)\
**Post date:** [January 10, 2020, 1:17pm UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/15 "2020-01-10T13:17:41Z")

</div>

Hey everyone. I’d love to see the complete script as well, if possible. Great solution to an annoying problem. /E

---

<div class="post-metadata">

**Author:** ![minyoungch](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@minyoungch](https://forum.dynamobim.com/u/minyoungch)\
**Post date:** [May 21, 2020, 9:58am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/16 "2020-05-21T09:58:04Z")

</div>

I’d love to see the complete script too

---

<div class="post-metadata">

**Author:** ![angadtiwari](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@angadtiwari](https://forum.dynamobim.com/u/angadtiwari)\
**Post date:** [July 11, 2022, 5:54am UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/17 "2022-07-11T05:54:49Z")

</div>

ahhh so happy to see people automating materials. Well i am working on something similar and its best to double check the lacing sometimes.

---

<div class="post-metadata">

**Author:** ![a.vlad](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@a.vlad](https://forum.dynamobim.com/u/a.vlad)\
**Post date:** [August 5, 2022, 5:04pm UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/19 "2022-08-05T17:04:18Z")

</div>

Hi, I’m trying to redo the same thing as you, and I manage to achieve the same results in the English version, however in the French version I have major difficulties with making everything work.  
I’m guessing it should be the “generic\_diffuse” part that needs to be translated from the english to the french, but I cannot find what I should replace it with.  
I don’t know python at all, I can guess how things work but idk where I could find the library of objects when I have such questions, can anyone points me in the right direction?

Regarding the other Dynamo librariers, I tried both Orchid and Genius Loci, and I’m having problems at the same point, when I need to change the colors of the material appearance asset, I have no idea how to do it, cause the language changes the labels I should put in…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/b/1bb4a07874069a0743dd0909c811e3a039db8225.png)

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [August 5, 2022, 7:02pm UTC](https://forum.dynamobim.com/t/create-materials-with-appearance-color-value-using-geniusloci-package/32316/20 "2022-08-05T19:02:59Z")

</div>

Hi,  
Please start a new thread and show a screenshot of your graph. You can link this topic as a reference.

> I’m guessing it should be the “generic\_diffuse” part that needs to be translated from the english to the french

I created the _Genius Loci_ nodes on a french Revit version so it’s not a matter of translating in french the code.
