I've used Jimmy Bergmark's code since he first posted it saved as "BackgroundChanger.LSP". We often get drawings from consultants with dark linework that can only be displayed on a white background.
When Lee Mac posted his color conversion code I replaced everything above:
; Set the background in model and paper space to grey
with:
;;; E-mail: info@jtbworld.com
;;; http://jtbworld.com/autocad-backgroundchanger-lsp
;;; 2003-07-01 - First release
;;; (load "BackgroundChanger.LSP") bgtg
;;; Macro: ^P(or bgtg (load "BackgroundChanger.LSP"));bgtg
;;; RCDATA_16_COLOR
;; RGB -> OLE - Lee Mac - Args: r,g,b - [int] Red, Green, Blue values
;; http://www.lee-mac.com/colourconversion.html#rgbole
;; ex. (LM:RGB->OLE 33 40 48) returns 3156001
(defun LM:RGB->OLE ( r g b )(logior (fix r) (lsh (fix g) 8) (lsh (fix b) 16)))
;; OLE -> RGB - Lee Mac - Args: c - [int] OLE Colour
(defun LM:OLE->RGB ( c )(mapcar '(lambda ( x ) (lsh (lsh (fix c) x) -24)) '(24 16 8)))
;; ex. (LM:OLE->RGB 3156001) returns (33 40 48)
Once it's loaded entering
(LM:RGB->OLE 230 230 219)
returns 14411494
Since I use the standard 33,40,48 as my BGGrey Background color I added the function:
; Background toggle between grey and white
(defun c:bgtg ()
(vl-load-com)
(setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
(setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object))))
(if (= (vlax-variant-value
(vlax-variant-change-type
(vla-get-graphicswinmodelbackgrndcolor disp)
vlax-vblong
)
)
(LM:RGB->OLE 33 40 48)
)
(c:BGWhite)
(c:BGGrey)
)
(princ)
)
which is just his bgt function modified to toggle to grey instead of black.