below is one example which works without using material ids or indices, just by using the material name:
# -*- coding: utf-8 -*-
import rhinoscriptsyntax as rs
ids = rs.GetObjects("Select objects", 8+16+32, True, True, True)
if not ids: return
# define path to the material and its name with extension
path = "D:\\Temp\\"
name = "Red Plastic.rmtl"
# load the material, surround path+name with quotes to prevent errors
cmd = "_RenderLoadMaterialFromFile "
rc = rs.Command(cmd + chr(34) + path + name + chr(34), False)
if not rc: return
# assign loaded material name (without extension) to selected objects
cmd = "_RenderAssignMaterialToObjects "
rc = rs.Command(cmd + chr(34) + name[0:-5] + chr(34), False)
if not rc: print "Error assigning material"
Note that you get an error message dialog if the material does not exists and if multiple materials are present with the same name in the material editor,
_RenderAssignMaterialToObjects prints an error to the command line and does not assign it.
@Alain, many of the material related methods are still missing in python rhinoscript syntax. Could you please add these to Rhino 6: