Script for color

Next
 From:  Edwin (DUELX24)
8304.1 
Hi, I am wondering is there a script to change viewport background color?
Thx
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Edwin (DUELX24)
8304.3 In reply to 8304.2 
Awesome thanks Michael!
The reason I asked this is, I have two different viewport lighting configurations set to shortcuts so I can switch between the two, and for one configuration I wanted the viewport color to change as well.

EDITED: 19 Feb by DUELX24

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All