python: change viewport background color?

196 views
Skip to first unread message

Andy Moorer

unread,
Jul 19, 2011, 3:37:36 PM7/19/11
to soft...@listproc.autodesk.com
Does anyone have a code snippet demonstrating changing scene display preferences like viewport background or default wireframe colors in python? I'm having trouble finding any documentation on which object might contain these properties... it's probably right in front of me, too... o_O

Bradley Gabe

unread,
Jul 19, 2011, 3:44:55 PM7/19/11
to soft...@listproc.autodesk.com
Application.SetValue("Preferences.SceneColors.backgroundcol", 2139062271, "")

Alan Fregtman

unread,
Jul 19, 2011, 3:49:43 PM7/19/11
to soft...@listproc.autodesk.com
# This example will cycle viewport bg color
# through grey/black/white/grey

prefs = Application.Preferences
bgcol = prefs.Categories("Scene Colors").backgroundcol

current = bgcol.Value
# 0 is black, -1 is pure white, 2139062271 is 50% grey.

actionTable = {
2139062271:0, # If grey, set it BLACK
0:-1, # If black, set it WHITE
-1:2139062271 # If white, set it GREY
}

if current in actionTable.keys():
bgcol.Value = actionTable[current]
else:
bgcol.Value = 2139062271 # If another color, set to grey.

Jason Brynford-Jones

unread,
Jul 19, 2011, 3:46:07 PM7/19/11
to soft...@listproc.autodesk.com
Look under scenecolors in the prefs.

Application.SetValue("preferences.Scenecolors.backgroundcol", "1361231465", "")

winmail.dat

Jason Brynford-Jones

unread,
Jul 19, 2011, 3:46:55 PM7/19/11
to soft...@listproc.autodesk.com
BTW did you know RMB on any pref you can restore defaults

Application.RestoreDefaultPreference("Scenecolors")

From: Jason Brynford-Jones
Sent: Tuesday, July 19, 2011 3:46 PM
To: soft...@listproc.autodesk.com
Subject: RE: python: change viewport background color?

Look under scenecolors in the prefs.

Application.SetValue("preferences.Scenecolors.backgroundcol", "1361231465", "")

From: softimag...@listproc.autodesk.com [mailto:softimag...@listproc.autodesk.com] On Behalf Of Andy Moorer
Sent: Tuesday, July 19, 2011 3:38 PM
To: soft...@listproc.autodesk.com
Subject: python: change viewport background color?

winmail.dat

Alan Fregtman

unread,
Jul 19, 2011, 4:03:10 PM7/19/11
to soft...@listproc.autodesk.com
And speaking of colors, did anyone know you can drag and drop
colorboxes between ppgs from separate XSI sessions?

Remarkable! :D

Ed Schiffer

unread,
Jul 19, 2011, 4:31:42 PM7/19/11
to soft...@listproc.autodesk.com
sorry, but as you're speaking about changing colors, how could I multiply every material's diffuse color by 2.2, for gamma correction?

Andy Moorer

unread,
Jul 19, 2011, 5:09:28 PM7/19/11
to soft...@listproc.autodesk.com
Awesome, thanks guys. It was right in front of me.... :)

find_X_test.jpg

find_X_test.jpg

Andy Moorer

unread,
Jul 19, 2011, 5:10:40 PM7/19/11
to soft...@listproc.autodesk.com
That's creepy and contrary to the natural order. Stop that.

Gareth Bell

unread,
Sep 29, 2011, 8:16:53 AM9/29/11
to soft...@listproc.autodesk.com

Potentially dumb question here......

 

Where does the 1361231465 come from? i.e. its not Hex or RGB etc

 

 


Stephen Blair

unread,
Sep 29, 2011, 9:12:31 AM9/29/11
to soft...@listproc.autodesk.com
winmail.dat

Gareth Bell

unread,
Sep 30, 2011, 11:35:19 AM9/30/11
to soft...@listproc.autodesk.com

magic, cheers

 


From: softimag...@listproc.autodesk.com [mailto:softimag...@listproc.autodesk.com] On Behalf Of Stephen Blair
Sent: 29 September 2011 14:13
To: soft...@listproc.autodesk.com
Subject: RE: python: change viewport background color?

Reply all
Reply to author
Forward
0 new messages