PDA

View Full Version : Set Background Color from a macro or toolbar button



bzrqmy
2006-07-21, 02:32 PM
I want to set the background color from within a macro or a toolbar button. Is there a sysrtem varialbe to set background color?

Mike.Perry
2006-07-22, 04:39 AM
Hi "bzrqmy" ( Sorry, I do not know your real name )

Please note I have *moved* this thread from the AutoCAD General (http://forums.augi.com/forumdisplay.php?f=120) forum to this one, as I feel this particular forum is a more appropriate place for such a topic.

Thanks, Mike

Forum Manager

Mike.Perry
2006-07-22, 04:45 AM
Hi

Do you mean Modelspace Colour...


(getenv "Background") ;Get ModelSpace Background colour (Integer)

(setenv "Background" "8355647") ;Set ModelSpace Background colour (Integer)As the above uses an Environment Variable, you need to type the name as shown ie UPPERlower case.

If you do not mean Modelspace Colour, please explain some more.

Have a good one, Mike

bzrqmy
2006-07-24, 11:27 AM
Thanks Mike,

How do I manipulate the number 8355647 to give me white or grey?

Thanks,

Pat Scott
Lansing, Mi

rkmcswain
2006-07-24, 12:01 PM
I want to set the background color from within a macro or a toolbar button. Is there a sysrtem varialbe to set background color?

No, there is not a system variable. But you can use vlisp code as shown below. This example function toggles the modelspace background color between white and black, and changes the crosshair color accordingly. Use of this code results in an immediate change of color compared to the changing of the environment variable.



(defun togbgcol ( / prefdisplay color)
(setq prefdisplay (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
(setq color (vlax-variant-value
(vlax-variant-change-type
(vla-get-graphicswinmodelbackgrndcolor prefdisplay)
vlax-vblong
)
)
)
(if (= color 0)
(progn (vla-put-graphicswinmodelbackgrndcolor
prefdisplay
(vlax-make-variant 16777215 vlax-vblong)
)
(vla-put-modelcrosshaircolor
prefdisplay
(vlax-make-variant 0 vlax-vblong)
)
)
(progn (vla-put-graphicswinmodelbackgrndcolor
prefdisplay
(vlax-make-variant 0 vlax-vblong)
)
(vla-put-modelcrosshaircolor
prefdisplay
(vlax-make-variant 16777215 vlax-vblong)
)
)
)
(vlax-release-object prefdisplay)
(princ)
)

Mike.Perry
2006-07-24, 08:40 PM
How do I manipulate the number 8355647 to give me white or grey? Hi

See if the following thread, helps...

Change the color of the graphic window background

Have a good one, Mike

bzrqmy
2006-07-25, 01:58 PM
It works Great, thanks for the help.

Pat