Jump to content

Toggle display color with LISP


Guest Flores

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • fuccaro

    8

  • NoelStalker

    5

  • CADTutor

    1

  • hendie

    1

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 :P

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...
Guest exout

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

Link to comment
Share on other sites

  • 3 years later...

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :(

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...