workspace background color

Can you alter one workspace background color and not affect the background of the others? I prefer 2D to be black and 3D to be gray or whatever it was in V13. Surely there is a way to do this instead of manually switching back and forth.

Comments

  • I came across this note on another forum, about creating a button to toggle between two background color
    =========================

    How to toggle background color through a toolbar button?
    Answer- You can use a Diesel macro utilizing the AutoCAD environment variable Background.
    Add a custom button with this macro (a single line):

    $M=$(if,$(eq,$(getenv,Background),0),
    _setenv;Background;16777215,_setenv;Background;0);_TILEMODE;0;_TILEMODE;1;

    Every click on this button will toggle the background color of your Modelspace window between black and white (of course you can set also different color pairs).
    =========================

    I don't know enough about Diesel to know how the logic works, or how gray would be set.
    -Joe
  • Joe is on the right track. The main steps are:
    1. Create a tool. Note on BC you have to use setvar to change the background.
    2. Edit your CUI. Add the tool to the 'On Switch' section of your workspace.
  • Or use a REACTOR, so when you change paperspace tabs the background is automatically changed like you are after.  You would then need to load the REACTOR in the onload.lsp file.....
  • This may need some tweaking, did not have time to test....

    [code]
    (defun c:ChgColorReactorOn ( \ *TabReactor*)
      (setvar 'nomutt 1)
      (setvar 'cmdecho 0)

      (defun ChgColor ( )
        (if (= (getvar 'wscurrent)"2d Drafting")
            (setvar 'bkgcolorps 256)    ;select to proper color here for 2D drafting
            (setvar 'bkgcolorps 5)       ;select to proper color here for 3D drafting
         )

    (setq *TabReactor*
         (VLR-Miscellaneous-Reactor tabname '((:VLR-layoutSwitched . ChgColor)))
        ) 
      (setvar 'nomutt 0)
      (setvar 'cmdecho 1) 
      );defun (C:ChgColorReactorOn)

    (defun c:ReactorOff ( )
      (vlr-remove-all :VLR-Miscellaneous-Reactor)
      );defun (c:ReactorOff)
    [/code]
  • This may need some tweaking, did not have time to test....

    (defun c:ChgColorReactorOn ( \ *TabReactor*)  (setvar 'nomutt 1)  (setvar 'cmdecho 0)  (defun ChgColor ( )    (if (= (getvar 'wscurrent)"2d Drafting")        (setvar 'bkgcolorps 256)    ;select to proper color here for 2D drafting        (setvar 'bkgcolorps 5)       ;select to proper color here for 3D drafting     )(setq *TabReactor*     (VLR-Miscellaneous-Reactor tabname '((:VLR-layoutSwitched . ChgColor)))    )   (setvar 'nomutt 0)  (setvar 'cmdecho 1)   );defun (C:ChgColorReactorOn)(defun c:ReactorOff ( )  (vlr-remove-all :VLR-Miscellaneous-Reactor)  );defun (c:ReactorOff)    


    I need to adjust this a bit, will do in a while no time right now....
  • Ok did a bit of testing, below works fine in Ver. 15

    [code]
    (defun c:ChgColorReactorOn ( / *TabReactor* tabname)
      (setvar 'nomutt 1)
      (setvar 'cmdecho 0)
      (defun ChgColor ( )
        (if (/= (getvar 'ctab) "Model")
          (if (= (getvar 'wscurrent)"2D Drafting")
        (setvar 'bkgcolorps 256)    ;select to proper color here for 2D drafting
        (setvar 'bkgcolorps 9)      ;select to proper color here for 3D drafting
        )
          )
        )
      (setq tabname (getvar 'ctab)
            *TabReactor*
         (VLR-Miscellaneous-Reactor tabname '((:VLR-layoutSwitched . ChgColor)))
        )
      (setvar 'nomutt 0)
      (setvar 'cmdecho 1) 
      );defun (C:ChgColorReactorOn)

    (defun c:ReactorOff ( )
      (vlr-remove-all :VLR-Miscellaneous-Reactor)
      );defun (c:ReactorOff)
    [/code]

    If you get odd results in other lisp functions you may need to turn off the reactor, type reactoroff to do so.

  • To install the above function automatically, just cut all code and paste into the "on_doc_load.lsp" file in the support directory where your version of Bricscad is located.

    If you do not yet have the file (does not come with Bricscad) then paste the code into Notepad and save as "on_doc_load.lsp" file in the support directory where your version of Bricscad is located.

    Then each time you open a file it will automatically be loaded.
  • Tim,

    There is a little more to this than changing the background. From what I can make out there are four different background types:
    1. BKGCOLOR/BKGCOLORPS. 2D wireframe Background settings for modelspace/paperspace.
    2. GradientColorTop, Middle, and Bottom. 3D Modelling gradient background settings for modelspace. Invoke by using the commands _GRADIENTBKGON and GRADIENTBKGOFF.
    3. HorizonBKG_GroundOrigin, GroundHorizon, GroundOrigin, SkyHigh, SkyLow, and SkyHorizon. Perspective mode background settings for modelspace. Invoke by using the command _PERSPECTIVE _ON / _OFF.
    4. _VIEW backgrounds. When you create a _VIEW, you can set its background and visual style.
    To make things more confusing, these interact with each other in different ways. _GRADIENTBKGON will prevent _PERSPECTIVE from using horizon settings, BKGCOLOR/BKGCOLORPS colors affect how objects highlight in the other background modes.

    If you're changing your background, you will also likely need to consider your _VISUALSTYLES too. As Roy pointed out you can use the 'OnSwitch' feature of workspaces to trigger a background change e.g.

    For 3D Modeling
    _GRADIENTBKGON;_-VISUALSTYLES _Current _Realistic;BKGCOLOR 7

    For 2D Drawing
    _GRADIENTBKGON;_-VISUALSTYLES _Current _Wireframe;BKGCOLOR 256

    Regards, Jason Bourhill CAD Concepts 

  • Whoops

    For 2D Drawing should be
    _GRADIENTBKGOFF;_-VISUALSTYLES _Current _Wireframe;BKGCOLOR 256


    and BKGCOLOR/BKGCOLORPS colors affect how objects display in the other background modes. e.g. if your using a light grey gradient background with 3d Modelling, then setting BKGCOLOR 256 will make objects drawn in white very difficult to see.


    Regards, Jason Bourhill CAD Concepts 
  • Thanks gentlemen. I'll look into each of these ideas.
This discussion has been closed.