Author Topic: True Colors  (Read 2741 times)

0 Members and 1 Guest are viewing this topic.

Serge J. Gianolla

  • Guest
True Colors
« on: April 22, 2004, 08:23:45 PM »
Has anyone played with True Colors programmatically in 2004/2005? Beyond the scene, how would you substitute the color of an object [assoc 62] to an accepted RGB value so one can then ENTMOD it, via LISP or VLISP? On screen listing an object returns the RGB, but entget returns the closest ACI! What's the trick?

SMadsen

  • Guest
True Colors
« Reply #1 on: April 23, 2004, 06:27:42 AM »
Code 62 holds the ACI only, so it will return the closest ACI when a truecolor is provided. You need to get hold of the code 420 that holds the RGB color.
Alternatively, you can access the TrueColor property. This little snippet will set color Bylayer:

(setq tco (vla-get-TrueColor obj))
(vlax-put-property tco 'ColorMethod acColorMethodByLayer)
(vlax-put-property obj 'TrueColor tco)

Once having an RGB color as the long expressed in code 420, you can convert it to RGB values and back again with something like this:

Code: [Select]
(defun Long2RGB (color / r g b)
  (setq r (fix (/ color 65536))
        g (fix (/ (- color (* r 65536)) 256))
        b (- color (* r 65536) (* 256 g)))
  (list r g b)
)

(defun RGB2Long (r g b)
  (+ (* r 65536) (* g 256) b)
)


Also note that if a colorbook is used to specify the color then code 430 will hold an entry to the colorbook (along with the RGB in 420 and the ACI in 62).

Serge J. Gianolla

  • Guest
True Colors
« Reply #2 on: April 23, 2004, 08:17:50 PM »
Yep, she works. 420 not 62 was the go. Thanks for that Stig.