C# Render Setting Background Color

Hi, i’m student in belgium

I would like to make a script allowing me to change the color of the rendering background.
I think I found the object properties in the documentation

Rhino.Render.RenderSettings

  private void RunScript(bool switcher, System.Drawing.Color colorTop, System.Drawing.Color colorBottom, ref object A)
  {
    if (switcher == true)
    {
      Rhino.Render.RenderSettings setting = new Rhino.Render.RenderSettings();

      setting.BackgroundColorTop = colorTop;
      setting.BackgroundColorBottom = colorBottom;
    }
    else
    {
    }
  }

I tried to change it but nothing happens because I think it is a new object with new parameters…

Do you know how I could send these new parameters in the viewport real time rendering ?

Best regards,

kub!

I finally found another way :slight_smile:

https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_RhinoDoc_ActiveDoc.htm

  private void RunScript(bool switcher, System.Drawing.Color colorTop, System.Drawing.Color colorBottom, ref object A)
  {
    if (switcher == true)
    {
      Rhino.RhinoDoc.ActiveDoc.RenderSettings.BackgroundColorTop = colorTop;
      Rhino.RhinoDoc.ActiveDoc.RenderSettings.BackgroundColorBottom = colorBottom;
    }
    else
    {
      Rhino.RhinoDoc.ActiveDoc.RenderSettings.BackgroundColorTop = System.Drawing.Color.FromArgb(255,255,255,255);
      Rhino.RhinoDoc.ActiveDoc.RenderSettings.BackgroundColorBottom = System.Drawing.Color.FromArgb(255,255,255,255);
    }

I hope this will help some people

1 Like