Hi @cyl, if you do not want to mess with material indices at all you could use
_RenderAssignMaterialToObjects "YourMaterialName"
in rs.Command().however this requires that you select the objects to which the material is assigned. To go the python route, you can find out all material names and indices from the material table. Something like below might help:
import scriptcontext
def FindMatIndexByMatName():
mat_table = scriptcontext.doc.Materials
index = mat_table.Find("White Matte", True)
if index >= 0:
print "MaterialIndex: {}".format(index)
else:
print "Not found"
if __name__=="__main__":
FindMatIndexByMatName()