TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PM on July 21, 2021, 03:18:52 AM

Title: Crosshair Color -Help
Post by: PM on July 21, 2021, 03:18:52 AM
Hi  am using this 2 code to change the crosshair color in model space to 40  and the second code to return  the crosshair color to default (white).

I want to update this code and in the first code convert the crosshair in model space to 40 and in layout to blue
and in the second code change the crosshair in model space and in layout ro deffault colors (white/black)

Code - Auto/Visual Lisp: [Select]
  1.  
  2. ;; Crosshair Color 40   <------- Add Blue to Layout
  3.  
  4.     (defun-q c:msc ( / d )
  5.         (eval
  6.             (list 'defun-q 'c:msc '( / c )
  7.                 (list 'setq 'c
  8.                     (list 'quote
  9.                         (list 49151
  10.                             (vla-get-modelcrosshaircolor
  11.                                 (setq d
  12.                                     (vla-get-display
  13.                                         (vla-get-preferences
  14.                                             (vlax-get-acad-object)
  15.                                         )
  16.                                     )
  17.                                 )
  18.                             )
  19.                         )
  20.                     )
  21.                 )
  22.                 (list 'vla-put-modelcrosshaircolor d '(car c))
  23.                '(setq c:msc (vl-list* (car c:msc) (list 'setq 'c (list 'quote (reverse c))) (cddr c:msc)))
  24.                '(princ)
  25.             )
  26.         )
  27.         (c:msc)
  28.     )
  29.     (vl-load-com) (princ)
  30.  
  31. ;; Crosshair Color white    <--- Default colors
  32.  
  33.  
  34.     (defun-q c:msc2 ( / d )
  35.         (eval
  36.             (list 'defun-q 'c:msc '( / c )
  37.                 (list 'setq 'c
  38.                     (list 'quote
  39.                         (list 16777215
  40.                             (vla-get-modelcrosshaircolor
  41.                                 (setq d
  42.                                     (vla-get-display
  43.                                         (vla-get-preferences
  44.                                             (vlax-get-acad-object)
  45.                                         )
  46.                                     )
  47.                                 )
  48.                             )
  49.                         )
  50.                     )
  51.                 )
  52.                 (list 'vla-put-modelcrosshaircolor d '(car c))
  53.                '(setq c:msc (vl-list* (car c:msc) (list 'setq 'c (list 'quote (reverse c))) (cddr c:msc)))
  54.                '(princ)
  55.             )
  56.         )
  57.         (c:msc)
  58.     )
  59.     (vl-load-com) (princ)
  60.  
  61.  
  62.  

Thanks
Title: Re: Crosshair Color -Help
Post by: PM on July 21, 2021, 06:19:09 AM
Any options?

Thanks
Title: Re: Crosshair Color -Help
Post by: BIGAL on July 21, 2021, 08:09:15 PM
Maybe the  'vla-put-layoutcrosshaircolor is supported so need to update that as well as Modelspacecrosshaircolor


Title: Re: Crosshair Color -Help
Post by: PM on July 22, 2021, 05:32:30 AM
Hi BIGAL. I dont know the codes for the colors. I can not find a list with color and codes . So i dont know the black and the blue color

Thanks
Title: Re: Crosshair Color -Help
Post by: PM on July 22, 2021, 05:51:24 AM
Ok the Blue works now but the second root (c:msc2)  is not working .
 
Code - Auto/Visual Lisp: [Select]
  1. ;; Crosshair Color 40 and Blue
  2.  
  3.     (defun-q c:msc ( / d )
  4.         (eval
  5.             (list 'defun-q 'c:msc '( / c )
  6.                 (list 'setq 'c
  7.                     (list 'quote
  8.                         (list 49151
  9.                             (vla-get-modelcrosshaircolor
  10.                                 (setq d
  11.                                     (vla-get-display
  12.                                         (vla-get-preferences
  13.                                             (vlax-get-acad-object)
  14.                                         )
  15.                                     )
  16.                                 )
  17.                             )
  18.                         )
  19.                     )
  20.                 )
  21.                 (list 'vla-put-modelcrosshaircolor d '(car c))
  22.                '(setq c:msc (vl-list* (car c:msc) (list 'setq 'c (list 'quote (reverse c))) (cddr c:msc)))
  23.                '(princ)
  24.             )
  25. )
  26. ;; Change crosshair color to BLUE here.
  27. (vlax-make-variant 16711680 19)
  28.         )
  29.         (c:msc)
  30.     )
  31.     (vl-load-com) (princ)
  32.  
  33. ;; Crosshair Color white and Black
  34.  
  35.  
  36.     (defun-q c:msc2 ( / d )
  37.         (eval
  38.             (list 'defun-q 'c:msc2 '( / c )
  39.                 (list 'setq 'c
  40.                     (list 'quote
  41.                         (list 16777215
  42.                             (vla-get-modelcrosshaircolor
  43.                                 (setq d
  44.                                     (vla-get-display
  45.                                         (vla-get-preferences
  46.                                             (vlax-get-acad-object)
  47.                                         )
  48.                                     )
  49.                                 )
  50.                             )
  51.                         )
  52.                     )
  53.                 )
  54.                 (list 'vla-put-modelcrosshaircolor d '(car c))
  55.                '(setq c:msc2 (vl-list* (car c:msc2) (list 'setq 'c (list 'quote (reverse c))) (cddr c:msc2)))
  56.                '(princ)
  57.             )
  58. )
  59. ;; Change crosshair color to BLACK here.
  60. (vlax-make-variant 0 19)
  61.         )
  62.         (c:msc2)
  63.     )
  64.     (vl-load-com) (princ)
  65.  
  66.  

Thanks
Title: Re: Crosshair Color -Help
Post by: PM on July 22, 2021, 12:00:08 PM
it's my mistake. I fix thanks
Title: Re: Crosshair Color -Help
Post by: JohnK on July 22, 2021, 12:18:31 PM
So, what is the fix (for other people, now or in the future, with the same problem)?
Title: Re: Crosshair Color -Help
Post by: BIGAL on July 22, 2021, 11:04:01 PM
I had a play, I used a Lee-mac program to work out the color code numbers. http://lee-mac.com/colourconversion.html I will have to go through again but got 40 = 49151
Title: Re: Crosshair Color -Help
Post by: tombu on July 23, 2021, 08:06:50 AM
I had a play, I used a Lee-mac program to work out the color code numbers. http://lee-mac.com/colourconversion.html I will have to go through again but got 40 = 49151
I convert using AutoCAD True Color RGB for my background changer that toggles all my display colors.

Code: [Select]
;; RGB -> OLE  -  Lee Mac - Args: r,g,b - [int] Red, Green, Blue values
;; http://www.lee-mac.com/colourconversion.html#rgbole
;; ex. (LM:RGB->OLE 33 40 48) returns 3156001
(defun LM:RGB->OLE ( r g b )(logior (fix r) (lsh (fix g) 8) (lsh (fix b) 16)))
;; OLE -> RGB  -  Lee Mac - Args: c - [int] OLE Colour
(defun LM:OLE->RGB ( c )(mapcar '(lambda ( x ) (lsh (lsh (fix c) x) -24)) '(24 16 8)))
;;  ex. (LM:OLE->RGB 3156001) returns (33 40 48)
Example:
Code: [Select]
(vla-put-GraphicsWinModelBackgrndColor disp (LM:RGB->OLE 33 40 48)) ; Default dark gray=(LM:RGB->OLE 33 40 48)=3156001
Title: Re: Crosshair Color -Help
Post by: BIGAL on July 25, 2021, 09:36:07 PM
Thanks Tombu I think the answer was colour to RGB then to Ole so got number. Big thanks though to Lee.
Title: Re: Crosshair Color -Help
Post by: Lee Mac on July 26, 2021, 03:37:06 PM
Thanks all - glad you could make use of the functions  :-)