Is there a way to click on an object and have it's color be the current color in the Color Control dropdown? Or some similar way to change the color control?
Thanks
Solved! Go to Solution.
Solved by 3wood. Go to Solution.
Hi,
You need a little help from Autolisp to do it:
(defun c:setcecolor (/ cecolor ent)
(setq ent (car(entsel)))
(if ent
(if (setq cecolor (cdr (assoc 62 (entget ent))))
(setvar "CECOLOR" (itoa cecolor))
(alert "The selected entity has color set to Bylayer")
)
)
)
Gaston Nunez
Something like this one?
(defun C:SetColorByObject (/ color colormethod bookname) ;;; SetColorByObject.lsp By 3wood (2014.11.12) (vl-load-com) (prompt "\nPick up an object to set current color:") (setq color (vla-get-truecolor (vlax-ename->vla-object(car(entsel)))) colormethod (vla-get-colormethod color) bookname (vla-get-bookname color) ) (cond ((= colormethod 192) (setvar "cecolor" "BYLAYER")) ((= colormethod 193) (setvar "cecolor" "BYBLOCK")) ((= colormethod 195) (setvar "cecolor" (itoa (vla-get-colorindex color)))) ((and (= colormethod 194)(= bookname "")) (setvar "cecolor" (strcat "RGB:" (itoa (vla-get-red color)) "," (itoa (vla-get-green color)) "," (itoa (vla-get-blue color)) ))) ((= colormethod 194)(setvar "cecolor" (strcat bookname "$" (vla-get-colorname color)))) ) (princ) )
Here's a way that gets around the fact that there's no (assoc 62) entry in entity data for objects whose color is ByLayer:
(setvar 'cecolor (itoa (vla-get-color (vlax-ename->vla-object (car (entsel "\nSelect object to set its color current: "))))))
[It does require (vl-load-com) first if that hasn't already been done.]