TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: pyreflos on November 29, 2017, 09:13:58 PM

Title: get TrueColor for every layer & make it dtext
Post by: pyreflos on November 29, 2017, 09:13:58 PM
I'm putting together a script that draws a line, and writes out the layer name, description, color, & lineweight for every layer in a drawing. It works great. But I want it to also give me the rgb color value. It's easy enough grab the info, but I can't seem to print it...

I can get color (indexed) and truecolor (RGB):
(setq layc (vla-get-Color lay))
(setq laytc (vla-get-TrueColor lay))

And I can write out indexed color:

(command "text" "j" "ml" (list dx5 dyy) "0.09375" "0" layc)
"5"

But TrueColor is confounding me... the closest I get is:

(command "text" "j" "ml" (list dx6 dyy) "0.09375" "0" (vl-princ-to-string laytc)) ;;; works, bad form
"#<VLA-OBJECT IAcadAcCmColor 0000000072c40f90>"

I also tried this, which chokes on layer one and stops the script:
(command "text" "j" "ml" (list dx5 dyy) "0.09375" "0" laytc)  ;;; does not work
"Enter text: ; error: bad argument value: AutoCAD command: #<VLA-OBJECT IAcadAcCmColor 0000000072ab2ca0>"

Does anyone know what form true color is in and how to convert ir to a "r,g,b" string?
Title: Re: get TrueColor for every layer & make it dtext
Post by: BIGAL on November 29, 2017, 10:48:12 PM
here is one way just "get" the red green blue
Command: (vlax-dump-object laytc)
; IAcadAcCmColor: AutoCAD AcCmColor Interface
; Property values:
;   Blue (RO) = 255
;   BookName (RO) = ""
;   ColorIndex = 4
;   ColorMethod = 195
;   ColorName (RO) = ""
;   EntityColor = -1023410172
;   Green (RO) = 255
;   Red (RO) = 0
T
Title: Re: get TrueColor for every layer & make it dtext
Post by: ronjonp on November 30, 2017, 09:56:34 AM
Code - Auto/Visual Lisp: [Select]
  1.   ","
  2.          (mapcar '(lambda (x) (strcat (itoa (vlax-get laytc x)) ",")) (list 'red 'green 'blue))
  3.   )
  4. )
Title: Re: get TrueColor for every layer & make it dtext
Post by: BIGAL on November 30, 2017, 07:16:47 PM
Nice one ronjop very usefull where you want more than one item a couple comes to mind 'startpoint 'endpoint
Title: Re: get TrueColor for every layer & make it dtext
Post by: Grrr1337 on November 30, 2017, 07:24:46 PM
FWIW you could avoid the multiple quotes:

Code: [Select]
(list 'red 'green 'blue)>>>
Code: [Select]
'(red green blue)