Guest Flores Posted November 5, 2003 Share Posted November 5, 2003 I used to have a routine that toggled the display color from black to white. It was written in VLISP, but I cannot find it anymore. I used it for saving images with a white background, then I would toggle the screen back to black. Does anyone have this routine or one similar to it? Flores Quote Link to comment Share on other sites More sharing options...
CADTutor Posted November 5, 2003 Share Posted November 5, 2003 This may help somewhat: http://www.civil.bcit.ca/faculty/thurston/acad/ACADFAQ2_copy.HTMl It details the use of the WMFBKGND variable. This can be used to change the background of objects copied to the clipboard from the background color to transparent. I assume that there must also be a system variable that controls the background colour and a LISP routine could easily be used to change it but short of ploughing through the full list I can't tell you what that variable is. Quote Link to comment Share on other sites More sharing options...
Guest Flores Posted November 5, 2003 Share Posted November 5, 2003 WMFBKGND seems to be only useful when using the "wmfout" command. It doesn't help with the "saveimg" > .bmp. Wmfout doesn't work with render: Render + wmfout = wireframe image. Hide + wmfout = correct image. Shade + wmfout = hidden image, no shade. As far as rendering images and background colors go: Type in "background" at the command line > Solid Radio button: Uncheck "Autocad Background" > move all sliders to the right so the 3 colors in the RGB color system is "1.00". Now whenever you render, it will have a white background regardless of the display color. I do not know if it is possible to change the background color with LISP, I believe it has to be done with VLISP. Flores Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 6, 2003 Share Posted November 6, 2003 The system variable called RIBACKGROUND was used for this, but it is no longer available. So you will need Visual Lisp or VBA to change the background collor. Quote Link to comment Share on other sites More sharing options...
Guest Flores Posted November 6, 2003 Share Posted November 6, 2003 This worked pretty good... it only takes 2 letters to go back and forth between the colors, but I would still like to make it work as a toggle. *********************************************** ;;Background color changer ;;Gary Maze, SMC Corporation of America ;;11/27/02 ;; ;;acadobject is the ActiveX component of the AutoCad instance ;;acadpref is the preferences property of acadobject ;;acaddisp is the display property of acadpref ;;the background color is the windows color number calculated ;;by the following formula; ;;(65536*blue)+(256*green)+red, where blue, green and red can ;;be 0 (off) to 255 (all the way on) ;;WB makes a whitebackground with a black crosshair (defun c:wb () ;;white background (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) ) ;;BB makes a black background with a white crosshair (defun c:bb () ;; black background ;(defun c:blackback (/ acadobject acadpref acaddisp) _(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) _) ;The user just wanted to change his background color to white, but I ; thought it might be nice to add a restore function as well. ******************************************** Flores Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 12, 2003 Share Posted November 12, 2003 This is the first time I "touch" a VL routine. I am sure that this is not the easiest way, but it works! Flores, now you can create a button for toggle the background color. If it does not work, do not call me: I must admit that I do not understand completely how it works, I just decided to start learning VL. ;;Background color changer ;;Gary Maze, SMC Corporation of America ;;11/27/02 ;; ;modified by Miklos Fuccaro ;mfuccaro@hotmail.com ;November 2003 ; (defun 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)) ) What's up, Hendie? Hendie, did you read the code? And now you can not stop laughing? Quote Link to comment Share on other sites More sharing options...
hendie Posted November 13, 2003 Share Posted November 13, 2003 fuccaro, I haven't had the chance to try out your code yet but rest assured I will not be laughing if it doesn't work (I'm sure it does !). I have written thousands of lines of code that does not work Quote Link to comment Share on other sites More sharing options...
Guest Flores Posted November 13, 2003 Share Posted November 13, 2003 Thanks Fuccaro it worked as expected . I just had to change the first line from (defun toggle_BackGround_color() to (defun c:toggle_BackGround_color() and then I made a macro for the button: ^C^C(if c:toggle_BackGround_color (princ)(load "toggle_BackGround_color")) toggle_BackGround_color and made sure that the folder that I saved it to was in the search path. Now I can simply press a button to toggle the screen. Flores Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 13, 2003 Share Posted November 13, 2003 Great, Flores! Together we are the smartest people around here Quote Link to comment Share on other sites More sharing options...
Guest exout Posted July 29, 2005 Share Posted July 29, 2005 hi, i found this topic because i had the exact same problem. now i tried to use the code, but actually i don'T really know how to use it.. i saved it as a .lsp file, then loaded it in autocad as an application. now i made a button with the commandline flores wrote (tried the whole thing with and without the "c:"), but it just doesnt work. am i doing anything wrong? where do i have to save the file? i'm using acad2006. thanks! eX Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 5, 2008 Share Posted November 5, 2008 I would like to make a command to toggle between white and black background as well. I tried Flores' lisp file and it did not work. It returned this error: Command: WB ; error: no function definition: VLAX-GET-ACAD-OBJECT Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 5, 2008 Share Posted November 5, 2008 Try to add (vl-load-com) after the line (defun toggle_BackGround_color() Other than that I don't know. Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 5, 2008 Share Posted November 5, 2008 fuccaro, Thanks for the response. I don't see (defun toggle_BackGround_color() in here: *********************************************** ;;Background color changer ;;Gary Maze, SMC Corporation of America ;;11/27/02 ;; ;;acadobject is the ActiveX component of the AutoCad instance ;;acadpref is the preferences property of acadobject ;;acaddisp is the display property of acadpref ;;the background color is the windows color number calculated ;;by the following formula; ;;(65536*blue)+(256*green)+red, where blue, green and red can ;;be 0 (off) to 255 (all the way on) ;;WB makes a whitebackground with a black crosshair (defun c:wb () ;;white background (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) ) ;;BB makes a black background with a white crosshair (defun c:bb () ;; black background ;(defun c:blackback (/ acadobject acadpref acaddisp) _(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) _) ;The user just wanted to change his background color to white, but I ; thought it might be nice to add a restore function as well. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 6, 2008 Share Posted November 6, 2008 Firstly try to enter that line into the command line. After that if the program works, we will find a place to insert that line right in the program. Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 6, 2008 Share Posted November 6, 2008 Fuccaro, I entered that command on the command line and then tried to run the lisp. This is what happened Command: (defun toggle_BackGround_color() (_> wb (_> bb (_> *Cancel* ; error: Function cancelled Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 7, 2008 Share Posted November 7, 2008 Here is what I meant: - Load the Lisp program: Tools>Load application... - Enter in the command line (vl-load-com) - Start the program by entering in the command line (WB) Unfortunately I don't have AutoCAD 2005 to try it out Quote Link to comment Share on other sites More sharing options...
rookie37 Posted November 7, 2008 Share Posted November 7, 2008 I would like this program. How do I load and execute a vba or visual lisp By the way, which one is this? ;;WB makes a whitebackground with a black crosshair (defun c:wb () ;;white background (setq acadobject (vlax-get-acad-object)) (setq acadpref (vlax-get-property acadobject 'preferences)) _(setq acaddisp (vlax-get-property acadpref 'display)) _ _ _(vlax-put-property acaddisp Will it work on acad 2004 that I used at home? Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 7, 2008 Share Posted November 7, 2008 fuccaro, I tried what you suggested. Here is a copy of my command line Command: appload background color changer (doesn't work).lsp successfully loaded. Command: Command: Command: (vl-load-com) Command: (WB) ; error: no function definition: WB Perhaps we should go about this a different way. Is there a variable that I can change? Can I type in a command like "background" and then type in the color? If so then I could make a lisp file. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 7, 2008 Share Posted November 7, 2008 I am so sorry for loosing your time! Load the Lisp and type in the command line: (TOGGLE_BACKGROUND_COLOR) When I previously read your request I was at home, without AutoCAD. Now I tested and it works for me. Sorry again! Quote Link to comment Share on other sites More sharing options...
NoelStalker Posted November 10, 2008 Share Posted November 10, 2008 fuccaro Of course! I should read the code. Thanks so much for your help. Have a great day. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.