viewport background toggle

I used to have on my work machine a usefull little script that allows to toggle the background color of the viewport. Say to capture the viewport in order to print it, I used to switch between Black for work and White to save and print. Does anyone remember where this script can be found? Thanks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jrulier's picture

Thanks a lot guys! Change

Thanks a lot guys! Change the viewport background color is the one so when I grab the viewport image to print, white background save my ink!

:)

"Will scan for food"

Anubis's picture

I find that in your code

I find that in your code missed color conversion. Its added only to color property of colorpicker. And i think is good to know, so there you go ...

fn UIColorToRGB clr = (color (clr.x*255) (clr.y*255) (clr.z*255))
fn RGBToUIColor clr = [clr.r/255,clr.g/255,clr.b/255]
-- tests ...
rgb_color = getVPortBGColor() -- (color 125 125 125)
ui_color = GetUIColor 41 -- [0.490196,0.490196,0.490196]
UIColorToRGB ui_color -- (color 125 125 125)
RGBToUIColor rgb_color -- [0.490196,0.490196,0.490196]
-- so adding conversion to your function and will become:
setBckgroundColor (UIColorToRGB cp_clr1.color)

-----------
finally i rewrite my code and upload it here:
http://www.scriptspot.com/3ds-max/swap-background-color
-----------

my recent MAXScripts RSS (archive here)

Anubis's picture

Ops.., then Jrulier look for

Ops.., then Jrulier look for this script:
http://www.scriptspot.com/3ds-max/sergos-script-pack

It use setVPortBGColor() function.
There is snippet code then:

def_color = getVPortBGColor()
clrWhite = setVPortBGColor(white);completeRedraw()
clrBlack = setVPortBGColor(black);completeRedraw()
-- restore default color by:
setVPortBGColor(def_color);completeRedraw()

or in my utility can replace cases with

case rb_clr.state of (
	1: setVPortBGColor(cp_clr1.color)
	2: setVPortBGColor(cp_clr2.color)
	3: setVPortBGColor(cp_clr3.color) )

-- P.S. colorMan used some diferent color matrix, for example:

getVPortBGColor() -- (color 125 125 125)
GetUIColor 41 -- [0.490196,0.490196,0.490196]

and this conversion "(color ((GetUIColor 41).x*255) ((GetUIColor 41).y*255) ((GetUIColor 41).z*255))" return unexpected colors, and change default color (color 125 125 125) to (color 175 175 175).

my recent MAXScripts RSS (archive here)

Marco Brunetta's picture

I think he needs to change

I think he needs to change the viewport background color, not the scene background. If that is the case, the code could be modified as such:

rollout swapBgrColor "Swap background color"
(
fn setBckgroundColor theColor =
(
SetUIColor 41 theColor
colorMan.repaintUI #repaintAll
)

radiobuttons rb_clr labels:#("1 ", "2 ", "3 ") columns:3
colorpicker cp_clr1 "" color:[0,0,0] across:3
colorpicker cp_clr2 "" color:[255,255,255]
colorpicker cp_clr3 "" color:(color ((GetUIColor 41).x*255) ((GetUIColor 41).y*255) ((GetUIColor 41).z*255))
button btn_bgrCrl "Set background Color" width:140

on btn_bgrCrl pressed do
(
case rb_clr.state of
(
1: setBckgroundColor cp_clr1.color
2: setBckgroundColor cp_clr2.color
3: setBckgroundColor cp_clr3.color
)
)
)

createDialog swapBgrColor

Anubis's picture

I hope this help utility


I hope this help

utility swapBgrColor "Swap background color"
(
	radiobuttons rb_clr labels:#("1     ", "2     ", "3     ") columns:3
	colorpicker cp_clr1 "" color:[0,0,0] across:3
	colorpicker cp_clr2 "" color:[255,255,255]
	colorpicker cp_clr3 "" color:[0,0,255]
	button btn_bgrCrl "Set background Color" width:140
 
	on btn_bgrCrl pressed do (
		case rb_clr.state of (
			1: backgroundColor = cp_clr1.color
			2: backgroundColor = cp_clr2.color
			3: backgroundColor = cp_clr3.color )
	)
)
AttachmentSize
swapBgrColor.ms 492 bytes

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.