+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22
  1. #1
    Flores
    Guest

    Default Toggle display color with LISP

    Registered forum members do not see this ad.

    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

  2. #2
    Administrator CADTutor's Avatar
    Computer Details
    CADTutor's Computer Details
    Operating System:
    Windows 7 Home Premium 64bit
    Motherboard:
    Asus P7P55D-E PRO
    CPU:
    Intel Core i7-860
    RAM:
    4GB PC3-12800 C8 Corsair Dominator
    Graphics:
    NVIDIA Quadro FX 1800 768 MB
    Primary Storage:
    Intel X25-M SSD 160GB
    Secondary Storage:
    Samsung Spinpoint 320GB
    Monitor:
    BenQ FP241W 24" Wide
    Discipline
    Education
    CADTutor's Discipline Details
    Occupation
    Senior Lecturer (Digital Design), Landscape Architect & Web Designer
    Discipline
    Education
    Using
    AutoCAD 2015
    Join Date
    Aug 2002
    Location
    Hampshire, UK
    Posts
    3,739

    Default

    This may help somewhat: http://www.civil.bcit.ca/faculty/thu...FAQ2_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.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
    AutoCAD Tutorials | How to add images to your posts | How to register successfully | Forum FAQ

  3. #3
    Flores
    Guest

    Default

    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

  4. #4
    Super Moderator fuccaro's Avatar
    Discipline
    Mechanical
    fuccaro's Discipline Details
    Occupation
    Mechanical eng.
    Discipline
    Mechanical
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,577

    Default

    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.
    It's nice to be nice, but sometimes is nicer to be evil!
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  5. #5
    Flores
    Guest

    Default

    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.

    Code:
    ***********************************************
    ;;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

  6. #6
    Super Moderator fuccaro's Avatar
    Discipline
    Mechanical
    fuccaro's Discipline Details
    Occupation
    Mechanical eng.
    Discipline
    Mechanical
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,577

    Default

    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.
    Code:
    ;;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?
    It's nice to be nice, but sometimes is nicer to be evil!
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  7. #7
    Super Member
    Using
    AutoCAD 2007
    Join Date
    Aug 2003
    Location
    Livingston, Scotland
    Posts
    995

    Default

    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

  8. #8
    Flores
    Guest

    Default

    Thanks Fuccaro it worked as expected . I just had to change the first line from
    Code:
    (defun toggle_BackGround_color()
    to
    Code:
    (defun c:toggle_BackGround_color()
    and then I made a macro for the button:
    Code:
    ^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

  9. #9
    Super Moderator fuccaro's Avatar
    Discipline
    Mechanical
    fuccaro's Discipline Details
    Occupation
    Mechanical eng.
    Discipline
    Mechanical
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,577

    Default

    Great, Flores!
    Together we are the smartest people around here
    It's nice to be nice, but sometimes is nicer to be evil!
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  10. #10
    exout
    Guest

    Default help

    Registered forum members do not see this ad.

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts