Author Topic: get TrueColor for every layer & make it dtext  (Read 184 times)

0 Members and 1 Guest are viewing this topic.

pyreflos

  • Mosquito
  • Posts: 1
get TrueColor for every layer & make it dtext
« 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?

BIGAL

  • Newt
  • Posts: 102
  • 30 + years of using Autocad
Re: get TrueColor for every layer & make it dtext
« Reply #1 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
A man who never made a mistake never made anything

ronjonp

  • Needs a day job
  • Posts: 6432
Re: get TrueColor for every layer & make it dtext
« Reply #2 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. )

Windows 10 x64 - AutoCAD /C3D 2018

Custom Build PC

BIGAL

  • Newt
  • Posts: 102
  • 30 + years of using Autocad
Re: get TrueColor for every layer & make it dtext
« Reply #3 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
A man who never made a mistake never made anything

Grrr1337

  • Bull Frog
  • Posts: 453
Re: get TrueColor for every layer & make it dtext
« Reply #4 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)