Setting Material AppaeranceProperties by Dynamo/Python

Hello! I am trying to set all properties in Appearance tab (in particular reflectivity and tint) for a generic material using Dynamo/Python nodes, but everytime I get a null result. Here my python test code to set only reflectivity 0 deg. How can I get the flag and a value for it?
Any help?

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]

assetElems = toList(UnwrapElement(IN[0]))
values = toList(IN[1])

for assetElem, value in zip(assetElems, values):
appearanceAssetId = mat.AppearanceAssetId
assetElem = doc.GetElement(appearanceAssetId)
TransactionManager.Instance.EnsureInTransaction(doc)
with Visual.AppearanceAssetEditScope(assetElem.Document) as editScope:
editableAsset = editScope.Start(assetElem.Id)
reflectivity = editableAsset[“generic_reflectivity_at_0deg”]
reflectivity.Value = value/100
editScope.Commit(True)
TransactionManager.Instance.TransactionTaskDone()

if isinstance(IN[0], list): OUT = assetElems
else: OUT = assetElems[0]

I recommend using the genius lock package for this - has the many (MANY) exceptions dealt with and works wonders.

1 Like

Thank you for your reply!
Unfortunately in Genius loci package there are no nodes to set appearance reflectivity values (0 and 90 deg) or some other properties for materials. I tried to create a custom node as you can see above but it does not work and I get null after running. Can you check it?
Thank you.

Hi Simone,

There are indeed no nodes for reflectivity but there is one to define the color tint among other properties.