AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Re: AutoCAD Background color.

Here's a simple function that changes your bgcolor to any RGB values you like :

;CODING STARTS HERE

(defun bgcol (r g b / mycol)

(setq mycol (+ (* b 65536) (* g 256) r))

(command "VBASTMT"

(strcat "Thisdrawing.application.preferences.Display.GraphicsWinModelBackgrndColor = "

(itoa mycol)

)

)

);defun

;CODING ENDS HERE

I might add that if the color "numbers" look kinda weird, it's because they are computed a certain way. An OLE-color is a longint and is calculated this way :

Color = (blue * 65536) + (green * 256) + red
Call it from a loop with 3 changing integers and you'll have a psychedelic rush (or maybe not).

Stig Madsen

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website