CAD PANACEA HAS MOVED TO http://cadpanacea.com
09 February 2007
Toggle AutoCAD background          

If you have a need to toggle the AutoCAD background color between black and white, try this lisp routine. I switch to white for screen captures and then back to black using this frequently.

(vl-load-com)
(defun c:TBC (/ pref col)
(setq pref (vla-get-display
(vla-get-Preferences
(vlax-get-acad-object)
)
)
)
(setq col (vlax-variant-value
(vlax-variant-change-type
(vla-get-graphicswinmodelbackgrndcolor pref)
vlax-vblong
)
)
)
(if (zerop col)
(progn (vla-put-graphicswinmodelbackgrndcolor
pref
(vlax-make-variant 16777215 vlax-vblong)
)
(vla-put-modelcrosshaircolor
pref
(vlax-make-variant 0 vlax-vblong)
)
)
(progn (vla-put-graphicswinmodelbackgrndcolor
pref
(vlax-make-variant 0 vlax-vblong)
)
(vla-put-modelcrosshaircolor
pref
(vlax-make-variant 16777215 vlax-vblong)
)
)
)
(vlax-release-object pref)
(princ)
)

Labels:


PermaLink       Posted 2/09/2007 07:10:00 AM     
8 COMMENTS!


Comment from: Blogger Seth
Date: February 28, 2007 at 10:57:00 AM CST  

You are the man! Thanks so much for sharing this with the public. I do the same and was looking for a variable to do this.

-Seth


Comment from: Blogger Unknown
Date: May 1, 2007 at 4:03:00 PM CDT  

I like this idea a lot. But I get this: "error: no function definition: VLAX-GET-ACAD-OBJECT" when I try to use it.

Any idea what I've either done or haven't done?

Thanks
Mike


Comment from: Blogger R.K. McSwain
Date: May 1, 2007 at 4:24:00 PM CDT  

My bad...

You need to run (vl-load-com) once prior to running this.

You can put this at the top of the file outside the (defun)


Comment from: Blogger Unknown
Date: May 2, 2007 at 10:39:00 AM CDT  

Thanks. I actually put it in acad.lsp, since I'll be using a few different routines that need it in the future.

Works great now. But I have a few users that use custom background and crosshair colors. I'll need to save those old colors before changing things so I can set them back later.

Should be interesting.

Mike


Comment from: Blogger Samuli
Date: September 25, 2007 at 2:50:00 AM CDT  

Great! Thank you.
Can we have the same for layout mode?
What I need to change to make it happen?
-Sam


Comment from: Anonymous Anonymous
Date: November 10, 2008 at 3:14:00 PM CST  

I am running ACAD 2005. I loaded your lisp and ran it and ACAD returned this error:

Command: tbc
; error: no function definition: VLAX-GET-ACAD-OBJECT


Comment from: Anonymous Anonymous
Date: November 10, 2008 at 3:16:00 PM CST  

maybe I should read the comments first. r.k. mcswain's May 1st 2007 comment fixed the problem


Comment from: Blogger R.K. McSwain
Date: November 10, 2008 at 3:18:00 PM CST  

Noel,

I'm going to update the code in the post. I'm not sure why I didn't do this way back then...

Post a comment