TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on February 08, 2023, 12:35:21 PM

Title: Reactor to change AutoCAD background color
Post by: jlogan02 on February 08, 2023, 12:35:21 PM
Our drawings are live 100% of the time so we differentiate between revisions using color. We've reached the point that I expected, the newest color is either too close to one of our existing standard colors or revision colors, or the color looks great on screen but prints to light to read, or prints great but to dark on the screen.

I need to settle this, so my thought is, have the user set their background color to gray when using that color and back again when done.

I have no experience with reactors but it seems to me I could set the background color when the user pushes the button to the custom color routine for that color. Is there a userclick reactor?

I don't know. Anyone have any ideas?

J.
Title: Re: Reactor to change AutoCAD background color
Post by: danAllen on February 08, 2023, 02:48:56 PM
Why have colors directly translate to printed output? Using CTB or STB you can keep them separate.

If you have a user push a button, then that can run the code to change background color. No need for reactors.

I've thought about creating a reactor to change background for read-only drawings, to avoid my common mistake of opening one that someone else is working on, then forgetting it was RO and editing it. But then I need to have it also track switching tabs to switch color back, and it seemed too complicated.
Title: Re: Reactor to change AutoCAD background color
Post by: BIGAL on February 08, 2023, 06:51:05 PM
Look at post 11

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-for-changing-color-of-background-in-model-space/td-p/4724669
Title: Re: Reactor to change AutoCAD background color
Post by: baitang36 on February 08, 2023, 07:11:31 PM
Code - Auto/Visual Lisp: [Select]
  1. (defun c:chgsc(/ col DISPLAY)
  2.         (setq    DISPLAY    (vla-get-display
  3.                         (vla-get-preferences
  4.                                 (vla-get-application (vlax-get-acad-object))
  5.                         )
  6.                 )
  7.   )
  8.         (if (= (getenv "Background") "0") (setq col 255) (setq col 0))
  9.         (vla-put-graphicswinlayoutbackgrndcolor DISPLAY (vlax-make-variant
  10.                         (+ col (* col 256)(* col 65536))
  11.                         vlax-vblong
  12.         ))
  13.                         (+ col (* col 256)(* col 65536))
  14.                         vlax-vblong
  15.         ))
  16.         (princ)
  17. )
Title: Re: Reactor to change AutoCAD background color
Post by: jlogan02 on February 09, 2023, 04:21:17 PM
Thanks for the replies. Good places to start for sure.