TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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?
-
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
-
-
Nice one ronjop very usefull where you want more than one item a couple comes to mind 'startpoint 'endpoint
-
FWIW you could avoid the multiple quotes:
(list 'red 'green 'blue)
>>>
'(red green blue)