Material Creation/Override with Python

Shane, I believe this script will help you achieve what you want:

#Create or Update Materials based on List inputs

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
#Inputs

names = IN[0]
cols = IN[1]
costs = IN[2]

#New materials OUT list
newMaterials = []
#Overwritten materials OUT list
ovwMaterials = []

def ToRevitColor(dynamoColor):
	return Color(dynamoColor.Red, dynamoColor.Green, dynamoColor.Blue)
	
#Avoid instance input problem
if isinstance(names, list):
	names = names
else: names = [names]

if isinstance(cols, list):
	cols = cols
else: cols = [cols]

if isinstance(costs, list):
	costs = costs
else: costs = [costs]

#Iterate through the input names list
for n, cl, cs in zip(names,cols,costs):
	#Check if the material with the specified name already exists
	if Material.IsNameUnique(doc,n):
		#If name is unique, create material
		TransactionManager.Instance.EnsureInTransaction(doc)
		new_mat_id = Material.Create(doc, n)
		new_mat = doc.GetElement(new_mat_id)
		new_mat.Color = ToRevitColor(cl)
		new_mat_Cost = new_mat.get_Parameter(BuiltInParameter.ALL_MODEL_COST).Set(cs)

		TransactionManager.Instance.TransactionTaskDone()
		newMaterials.append(n)
	else:
		#If it already exists, collect it and modify it
		TransactionManager.Instance.EnsureInTransaction(doc)
		namePar = ParameterValueProvider(ElementId(BuiltInParameter.MATERIAL_NAME))
		fRule = FilterStringRule(namePar,FilterStringEquals(),n, True)
		filter = ElementParameterFilter(fRule)
		exist_mat = FilteredElementCollector(doc).OfClass(Material).WherePasses(filter).ToElements()
		#Iteration is necessary because the output of exist_mat is invariably a list
		for em in exist_mat:
			#Modify the Material Properties and Parameters
			em.Color = ToRevitColor(cl)
			emCost = em.get_Parameter(BuiltInParameter.ALL_MODEL_COST).Set(cs)
			ovwMaterials.append(n)
		TransactionManager.Instance.TransactionTaskDone()
		
OUT = newMaterials, ovwMaterials

It actually does what I initially intended to do, and a bit more. It checks if the material already exists in the document and, if not, creates a new one (with the properties and parameters as desired). If the material already exists, it overrides the properties and/or parameters of the element (Material). The problem I faced in my first attempt was that the methods to create and to modify a Material are different, so it is fundamental to find out if the element already exists or not at foremost. Since I don’t know which parameters and/or properties you intend to control, I left an example of each kind of operation. Also, the output of the node is set up to display which materials were created and which were overwritten. From this point it is easy to connect the materials with an outside source.

Best,
David