Code Red > AutoLISP (Vanilla / Visual)

Change crosshait color with lisp

<< < (2/3) > >>

Lee Mac:

--- Quote from: Stefan on June 13, 2021, 06:36:01 PM ---Nice one Lee, I like the way you switch the colors.

The only thing is, if the initial color is 40 when you load the lisp, nothing happens.
I had the same problem trying to store  the initial value with setenv. But if 40 is hard coded, white could be also hard coded.

--- End quote ---

Thanks Stefan - I take your point about the initial colour issue, though as you've gathered, if the initial colour is 40, the program has no way to determine what the 'normal' crosshair colour should be without hardcoding a default, and so in my opinion, this is moot.

Lonnie:
Not sure it helps but I did this years ago.



--- Code: ---(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 65986) ;;Model space background
(vlax-put-property acaddisp 'GraphicsWinLayoutBackgrndColor  63434) ;;command area
(vlax-put-property acaddisp 'ModelCrosshairColor 865785);; crosshairs
(vlax-put-property acaddisp 'TextWinBackgrndColor 3687) ;;command area

(princ "Done doing")

--- End code ---

You can see my old thread here if you like.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/changing-page-layout-paper-background-via-lisp/m-p/6390939#M342190

JohnK:
There isn't a need to hardcode the original value; just check and change.

--- Code - Auto/Visual Lisp: ---(defun toggleCursor ( / *disply-preferences* currentvalue)  ;; toggle the current cursor color from 40 to white (and vise versa)  (setq *disply-preferences*         (vla-get-display           (vla-get-preferences            (vlax-get-acad-object)))        currentvalue        (vlax-variant-value          (vlax-variant-change-type            (vla-get-modelcrosshaircolor *disply-preferences* )            vlax-vblong            )          )        )  (vla-put-modelcrosshaircolor     *disply-preferences*     (vlax-make-variant      (boole (- 7 (cond ((<= currentvalue 16777215) 1) (0)))             currentvalue             16728064)      vlax-vblong      )    )  )


EDIT: fixed spelling error in first sentence.

PM:
Where i can find the number for the colors

for example 49151 --> 40 and 16777215->white  ???? Is any list of colors and numbers ??

Thanks

Lee Mac:

--- Quote from: John Kaul (Se7en) on June 15, 2021, 11:29:33 AM ---There isn't a need to hardcode the original value; just check and change.
--- Code - Auto/Visual Lisp: ---;; toggle the current cursor color from 40 to white (and vise versa)
--- End quote ---

But here white is arbitrarily hardcoded as a default.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version