Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Change the color of the graphic window background

  1. #1
    Active Member todd.mackay's Avatar
    Join Date
    2003-03
    Posts
    74
    Login to Give a bone
    0

    Question Change the color of the graphic window background

    I'm looking for the code to change the color of the graphic window background. Normally it's set to black and I want to be able to change it to white for a Lisp routine. The reason is for exporting a *.wmf.

    Also, are there any web sites that I can search for codes?

    Thanks - Todd

  2. #2
    Mod / Salary / SM Wanderer's Avatar
    Join Date
    2001-12
    Location
    St. Louis
    Posts
    5,406
    Login to Give a bone
    0

    Talking Re: Change the color of the graphic window background

    Quote Originally Posted by todd.mackay
    I'm looking for the code to change the color of the graphic window background. Normally it's set to black and I want to be able to change it to white for a Lisp routine. The reason is for exporting a *.wmf.

    Also, are there any web sites that I can search for codes?

    Thanks - Todd
    The augi exchange http://www.augi.com/exchange/search.asp?page=415

    and cadalyst http://new.cadalyst.com/code/

    have lots of downloads available
    Melanie Stone
    @MistresDorkness

    Archibus, FMS/FMInteract and AutoCAD Expert (I use BricsCAD, Revit, Tandem, and Planon, too)
    Technical Editor
    not all those who wander are lost

  3. #3
    The Silent Type Mike.Perry's Avatar
    Join Date
    2000-11
    Posts
    13,656
    Login to Give a bone
    0

    Default Re: Change the color of the graphic window background

    Hi

    The below comes from an old ACAD Guild post (definitely go with Stig's method) -

    Code:
    ;|
    The AutoCAD Display colour number can be calculated with this formula:
    
    RGB value = (blue * 65536) + (green * 256) + red 
    
    To change the background colour, one could use the function below. It takes
    RGB values, each between 0-255. For example, a pure yellow background would
    be: (bgcol 255 255 0), or a black one: (bgcol 0 0 0), or a white one: (bgcol
    255 255 255) etc...
    
    By exploring the Display properties, you can change any colour that accepts
    the OLE Colours. Reason that it doesn't use pure ActiveX is that an OLE
    Colour uses a variant type that is currently unknown to Visual Lisp, so
    this is just a shortcut.
    
    Stig Madsen
    |;
    
    (defun bgcol (r g b / mycol invcol objtxt)
      (mapcar '(lambda (c)
    	  (cond ((< (eval c) 0) (set c 0))
    	 ((> (eval c) 255) (set c 255))
    	  )
    	)
       '(r g b)
      )
      (setq mycol  (+ (* b 65536) (* g 256) r)
     invcol (+ (* (- 255 b) 65536) (* (- 255 g) 256) (- 255 r))
     objtxt "Thisdrawing.application.preferences.Display"
      )
      (command
    	"VBASTMT"
    	(strcat objtxt
    	 ".GraphicsWinModelBackgrndColor = "
    	 (itoa mycol)
    	)
      )
      (command
    	"VBASTMT"
    	(strcat objtxt
    	 ".ModelCrossHairColor = "
    	 (itoa invcol)
    	)
      )
    )


    Code:
    ;|
    Toggles ModelSpace BackGround Colour between Black & White.
    Colour values are hard-coded.
    Am unhappy in the method I had to adopt to *force* Display to update.
    
    Mike Perry
    |;
    (defun C:ModelSpaceColour ()
      (cond
    	((= (getvar "TileMode") 0)  ;Check Space, Exit if not in ModelSpace
    	 (prompt
    	   "\n***Command only works in ModelSpace, TileMode = 1***"
    	 )
    	)
    	((= (getenv "Background") "16777215")
    	 ;ModelSpace Background colour = White
    	 (setenv "Background" "0")  ;Set ModelSpace Background colour = Black
    	 (setenv "XhairPickboxEtc" "16777215")
    	 ;Set ModelSpace Crosshair colour = White
    	 (setvar "TileMode" 0)  ;Force Display to update
    	 (setvar "TileMode" 1)
    	 (prompt "\n***ModelSpace Background colour set to Black***")
    	)
    	((= (getenv "Background") "0") ;ModelSpace Background colour = Black
    	 (setenv "Background" "16777215") ;Set ModelSpace Background colour = White
    	 (setenv "XhairPickboxEtc" "0") ;Set ModelSpace Crosshair colour = Black
    	 (setvar "TileMode" 0)  ;Force Display to update
    	 (setvar "TileMode" 1)
    	 (prompt "\n***ModelSpace Background colour set to White***")
    	)
    	(T	 ;Exit if ModelSpace Background colour /= Black or White
    	 (prompt "\n***ModelSpace Background colour not altered***")
    	)
      )
      (princ)
    )
    Have a good one, Mike

  4. #4
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Change the color of the graphic window background

    Here's what I came up with that is pure ActiveX and requires no regen.
    Code:
    ;|sub-routines to change Model Space & text window background & text
      color(s). Autocad colors 1 - 7 are supported, any other
      number, or nil, will go to black. Other colors can be added,
      just make sure to convert from Autocad color to
      OLE_COLOR number first. May need to adjust 
      text color as well.
      by Jeff Mishler, April 2004
      usage: (set_txt_bkgrnd 1) will set background to Red
      |;
    (defun set_txt_bkgrnd (color)
      (cond ((eq color 1)(setq color 255))
    	((eq color 2)(setq color 65535))
    	((eq color 3)(setq color 65280))
    	((eq color 4)(setq color 16776960))
    	((eq color 5)(setq color 16711680))
    	((eq color 6)(setq color 16711935))
    	((eq color 7)(setq color 16777215))
    	(t(setq color 1))
    	)
        (vla-put-TextWinBackgrndColor
          (vla-get-display
    	(vla-get-Preferences
    	  (vlax-get-acad-object)
    	  )
    	)
          color
          )
      )
    
    (defun set_txt_foregrnd (color)
      (cond ((eq color 1)(setq color 255))
    	((eq color 2)(setq color 65535))
    	((eq color 3)(setq color 65280))
    	((eq color 4)(setq color 16776960))
    	((eq color 5)(setq color 16711680))
    	((eq color 6)(setq color 16711935))
    	((eq color 7)(setq color 16777215))
    	(t(setq color 1))
    	)
        (vla-put-TextWinTextColor
          (vla-get-display
    	(vla-get-Preferences
    	  (vlax-get-acad-object)
    	  )
    	)
          color
          )
      )
    
    
    (defun set_MS_bkgrnd (color)
      (cond ((eq color 1)(setq color 255))
    	((eq color 2)(setq color 65535))
    	((eq color 3)(setq color 65280))
    	((eq color 4)(setq color 16776960))
    	((eq color 5)(setq color 16711680))
    	((eq color 6)(setq color 16711935))
    	((eq color 7)(setq color 16777215))
    	(t(setq color 1))
    	)
        (vla-put-GraphicsWinModelBackgrndColor
          (vla-get-display
    	(vla-get-Preferences
    	  (vlax-get-acad-object)
    	  )
    	)
          color
          )
      )
    Good luck,
    Jeff

  5. #5
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Smile Re: Change the color of the graphic window background

    Jeff,

    Please tell me what books on Visual Lisp you have been reading.
    Tell me you didn't get this knowledge for the on-line help section.

    CAB

  6. #6
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Change the color of the graphic window background

    Quote Originally Posted by ab2draft
    Jeff,

    Please tell me what books on Visual Lisp you have been reading.
    Tell me you didn't get this knowledge for the on-line help section.

    CAB
    LOL
    Uh, would you believe.......
    I spend ......
    more time than my wife appreciates
    more time than my partner would approve of (even though what I come up with saves him, me, and our employees a ton of time)
    enough time to read just about every meaningful post at:
    www.cadvault.com theswamp.org news:\\discussion.autodesk.com
    way too much time re-reading the on-line help section(s): Vlisp & VBA
    writing code for applications that I will NEVER use just so I can see how a certain object/method/property works or is affected by another.

    I have never read a printed book, other than David Stein's Vlisp Developer's Bible.

    I do enjoy the learning. And quite often I will write the code in standard lisp, then vlisp w/activex, then VBA just to see haow they are the samne and/or differ.

    Jeff

  7. #7
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Change the color of the graphic window background

    Well I guess there is vlisp hope for me yet.
    No easy way, just put in your time.

    CAB

  8. #8
    100 Club
    Join Date
    2000-12
    Posts
    126
    Login to Give a bone
    0

    Default Re: Change the color of the graphic window background

    Did I just see a definition of the word 'nerd' ?
    (where's that devil smilie when you need it?)

  9. #9
    Certifiable AUGI Addict robert.1.hall72202's Avatar
    Join Date
    2004-07
    Location
    Detroit Michigan
    Posts
    2,508
    Login to Give a bone
    0

    Default Re: Change the color of the graphic window background

    Quote Originally Posted by todd.mackay
    I'm looking for the code to change the color of the graphic window background. Normally it's set to black and I want to be able to change it to white for a Lisp routine. The reason is for exporting a *.wmf.

    Also, are there any web sites that I can search for codes?

    Thanks - Todd
    This gives me an I-dear.....anybody got a lisp routine for changing the background color in
    AutoCad drawing window from Black to White and back again???? Would be great since I constantly need to change to white for insertion into Microsoft office documents. Going through the options settings every time is such a pain in me arse.

  10. #10
    100 Club
    Join Date
    2000-12
    Posts
    126
    Login to Give a bone
    0

    Default Re: Change the color of the graphic window background

    Couldn't you just set the sysvar WMFBKGRND to 0 ?

Page 1 of 3 123 LastLast

Similar Threads

  1. Change Background Color for outside layout
    By Capt. Computer Crasher in forum AutoCAD General
    Replies: 2
    Last Post: 2009-11-17, 09:48 PM
  2. Change Paperspace Background Color with .NET
    By thomas.bucher in forum Dot Net API
    Replies: 1
    Last Post: 2008-09-09, 05:40 PM
  3. Change Background color of Cells
    By Jack Cheong in forum AutoCAD Tables
    Replies: 1
    Last Post: 2008-05-22, 11:33 AM
  4. Why would MS background change color?
    By kleenhippie in forum CAD Management - General
    Replies: 1
    Last Post: 2008-01-25, 03:06 PM
  5. Change Field background color
    By ccowgill in forum AutoCAD Fields
    Replies: 3
    Last Post: 2006-02-09, 01:09 PM

Posting Permissions

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