Set material color of a layer

I can set the color of the layer like this: MyLayer.Color = Drawing.Color.LightBlue

Is there a similarly simple way I can set the material color for that layer?

Thanks,
Sam

In Python:

import rhinoscriptsyntax as rs
mat_index = rs.AddMaterialToLayer("Default")
rs.MaterialColor(mat_index, (127, 255, 191))

Shoot, just realized I forgot to set the topic (thanks for updating) to developer and mention I’m working in Rhinocommon! Could please show me how this script would look in Rhinocommon?

This should work:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var layer_index = doc.Layers.FindByFullPath("Default", true);
  if (layer_index >= 0)
  {
    var layer = doc.Layers[layer_index];
    if (null != layer)
    {
      var material_index = layer.RenderMaterialIndex;
      if (material_index < 0)
      {
        var material = new Material { DiffuseColor = Color.BlanchedAlmond };
        material_index = doc.Materials.Add(material);
        layer.RenderMaterialIndex = material_index;
        doc.Layers.Modify(layer, layer.LayerIndex, true);
        doc.Views.Redraw();
      }
    }
  }
  return Result.Success;
}

Brilliant, everything looks much nicer now, thanks!

Sam