Script for color

 From:  Michael Gibson
8304.2 In reply to 8304.1 
Hi Edwin,

re:
> Hi, I am wondering is there a script to change viewport background color?

There is a control for setting the viewport background color in the regular UI, under Options > View > Colors > "Background color", so it isn't necessary to set up a script to do it. You can just click the color swatch right next to "Background color" to set it.


If you do want to control it from a script to do some kind of special automated thing, that is also possible by setting the moi.view.viewportBackgroundColor property, it takes an integer that has the Red, Green, Blue bytes packed together. You can set it with HTML like hexadecimal type color notation like this:

moi.view.viewportBackgroundColor = 0xFFFFFF;

Or if you want to set it with 0-255 decimal values for R, G, B, you would bit shift the Red and Green values up and combine them into a single color value like this:

var r = 25, g = 51, b = 255; moi.view.viewportBackgroundColor = (r << 16) | (g << 8) | b;

- Michael