Quick Way to Change Background Color
Quick Way to Change Background Color
(OP)
I am running AutoCAD 14.01 and need a way to quickly change my background color from black to white, and back to black again (without going through all the dialog boxes). Is there a way to change the status of a system variable to edit-able if it is read only (ie: CurrentProfile)? Is there a way to write a lisp routine to go behind the scenes and change that for me with a push of a button. I would like to be able to create two buttons, one for turning the screen white, and one for turning it back to black. Is this do-able?
Thanks!
Thanks!





RE: Quick Way to Change Background Color
---------------------------------------------------
try this..
(setq DisplayObj
(vla-get-Display
(vla-get-Preferences
(vlax-get-acad-object)
)))
(vlax-put-property DisplayObj 'GraphicsWinModelBackgrndColor 131)
(vlax-release-object DisplayObj)
the 131 is your color...so is the value to change if you want..
RE: Quick Way to Change Background Color
Lothar
(defun C:ToggleColors ()
(cond ((= 1 (getvar "tilemode"))
(ax:ToggleMsBackground)
(ToggleMsCrosshair)
)
((= 0 (getvar "tilemode"))
(ax:TogglePsBackground)
(TogglePsCrosshair)
)
)
(princ)
)
;;
(defun ax:ToggleMSBackground (/ prefDisplay)
(vl-load-com)
(setq
prefDisplay
(vla-get-Display
(vla-get-Preferences (vlax-get-acad-object))
)
color (vlax-variant-value
(vlax-variant-change-type
(vla-get-GraphicsWinModelBackgrndColor prefDisplay)
vlax-vbLong
)
)
)
(vla-put-GraphicsWinModelBackgrndColor
prefDisplay
(vlax-make-variant
(if (= color 0) ; 0 ist schwarz
16777215
0 ; 0 ist schwarz
)
vlax-vbLong
)
)
(princ)
)
;;
(defun ax:TogglePSBackground (/ prefDisplay)
(vl-load-com)
(setq
prefDisplay
(vla-get-Display
(vla-get-Preferences (vlax-get-acad-object))
)
color (vlax-variant-value
(vlax-variant-change-type
(vla-get-GraphicsWinLayoutBackgrndColor prefDisplay)
vlax-vbLong
)
)
)
(vla-put-GraphicsWinLayoutBackgrndColor
prefDisplay
(vlax-make-variant
(if (= color 0) ; wenn er schwarz ist
16777215 ; mach ihn weiß
0 ; mach ihn schwarz
)
vlax-vbLong
)
)
(princ)
)
;;
(defun ToggleMSCrosshair (/ prefDisplay)
(vl-load-com)
(setq
prefDisplay
(vla-get-Display
(vla-get-Preferences (vlax-get-acad-object))
)
color (vlax-variant-value
(vlax-variant-change-type
(vla-get-ModelCrosshairColor prefDisplay)
vlax-vbLong
)
)
)
(vla-put-ModelCrosshairColor
prefDisplay
(vlax-make-variant
(if (= color 0) ; wenn er schwarz ist
16777215 ; mach ihn weiß
0 ; mach ihn schwarz
)
vlax-vbLong
)
)
(princ)
)
(defun TogglePSCrosshair (/ prefDisplay)
(vl-load-com)
(setq
prefDisplay
(vla-get-Display
(vla-get-Preferences (vlax-get-acad-object))
)
color (vlax-variant-value
(vlax-variant-change-type
(vla-get-LayoutCrosshairColor prefDisplay)
vlax-vbLong
)
)
)
(vla-put-LayoutCrosshairColor
prefDisplay
(vlax-make-variant
(if (= color 0) ; wenn er schwarz ist
16777215 ; mach ihn weiß
0 ; mach ihn schwarz
)
vlax-vbLong
)
)
(princ)
)
RE: Quick Way to Change Background Color
Command: _appload
Loading C:\colorchange2.lsp ...
Error: null function*Cancel*
Any suggestions?
RE: Quick Way to Change Background Color
Below is a toggle for a black screen with white crosshairs, and vise-versa.
;;Background color changer
;;Gary Maze, SMC Corporation of America
;;11/27/02
;;
;;modified by Miklos Fuccaro
;;mfuccaro@hotmail.com
;;November 2003
;;
;; put this in a macro button to toggle screen color:
;; ^C^C(if c:toggle_BackGround_color (princ)(load "toggle_BackGround_color")) toggle_BackGround_color
;;
(defun c:toggle_BackGround_color()
(defun wb () ;;white background
(setq whitebackground T)
(setq acadobject (vlax-get-acad-object))
(setq acadpref (vlax-get-property acadobject 'preferences))
_(setq acaddisp (vlax-get-property acadpref 'display))
_ _ _(vlax-put-property acaddisp 'GraphicsWinmodelBackgrndColor 16777215)
_ _ _(vlax-put-property acaddisp 'ModelCrosshairColor 0)
)
(defun bb () ;; black background
(setq whitebackground nil)
_(setq acadobject (vlax-get-acad-object))
_(setq acadpref (vlax-get-property acadobject 'preferences))
_(setq acaddisp (vlax-get-property acadpref 'display))
_ (vlax-put-property acaddisp 'GraphicsWinmodelBackgrndColor 0)
_ (vlax-put-property acaddisp 'ModelCrosshairColor 16777215)
_)
(if whitebackground (bb) (wb))
)
Flores
RE: Quick Way to Change Background Color
RE: Quick Way to Change Background Color
To set background to black use (setenv "Background" "0")
and for white (setenv "Background" "16777215"). Note that the variable name is case sensitive. On my machine (using R2002) I had to toggle between modelspace and layout mode for change to take effect, which if needed you could include in the lisp routine/button.
RE: Quick Way to Change Background Color
"Layout background" - background color in layout mode. note the space
"XhairPickboxEtc" - crosshair color in modelspace
"LayoutXhairPickboxEtc" - crosshair color in layout mode