Jonathan Handojo Posted March 4 Posted March 4 (edited) 12 hours ago, Dien nguyen said: I used this lisp to convert the color of the object to true color. Now I'm looking for a way to change the color of all layers from RGB to TrueColor. I consulted Lee-Mac's website but I still don't know how to use it. Please help. Try this: (defun c:foo ( / accm c ly nm) (setq accm (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AutoCAD.AcCmColor." (substr (getvar 'ACADVER) 1 2)) ) ) (while (setq ly (tblnext "layer" (not ly))) (and (wcmatch (setq nm (cdr (assoc 2 ly))) "~*|*") (setq c (cdr (assoc 62 ly))) (progn (vla-put-ColorIndex accm c) (entmod (append (entget (tblobjname "layer" nm)) (list (cons 420 (apply 'LM:RGB->True (mapcar 'vlax-get-property (list accm accm accm) '(red green blue) ) ) ) ) ) ) ) ) ) (vlax-release-object accm) (princ) ) ;; RGB -> True - Lee Mac 2011 ;; Args: r,g,b - Red,Green,Blue values (defun LM:RGB->True (r g b) (+ (lsh (fix r) 16) (lsh (fix g) 8) (fix b) ) ) Edited March 4 by Jonathan Handojo 1 Quote
Dien nguyen Posted March 4 Posted March 4 10 hours ago, Jonathan Handojo said: Try this: (defun c:foo ( / accm c ly nm) (setq accm (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AutoCAD.AcCmColor." (substr (getvar 'ACADVER) 1 2)) ) ) (while (setq ly (tblnext "layer" (not ly))) (and (wcmatch (setq nm (cdr (assoc 2 ly))) "~*|*") (setq c (cdr (assoc 62 ly))) (progn (vla-put-ColorIndex accm c) (entmod (append (entget (tblobjname "layer" nm)) (list (cons 420 (apply 'LM:RGB->True (mapcar 'vlax-get-property (list accm accm accm) '(red green blue) ) ) ) ) ) ) ) ) ) (vlax-release-object accm) (princ) ) ;; RGB -> True - Lee Mac 2011 ;; Args: r,g,b - Red,Green,Blue values (defun LM:RGB->True (r g b) (+ (lsh (fix r) 16) (lsh (fix g) 8) (fix b) ) ) Thanks Jonathan, it works for me. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.