ScriptSpot

Forum topic · General Scripting

viewport background toggle

By jrulier · 2009-07-18

Description

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 (5)

jrulier · 2009-07-19

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!

:)

Anubis · 2009-07-19

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
-----------

Anubis · 2009-07-18

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).

Marco Brunetta · 2009-07-18

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

I hope this help utility

Anubis · 2009-07-18


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 )
	)
)
Attachments