Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to make current color in Color Contro the same as the color of an object

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
RChalmers2
1233 Views, 7 Replies

how to make current color in Color Contro the same as the color of an object

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

7 REPLIES 7
Message 2 of 8
hgasty1001
in reply to: RChalmers2

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

 

Message 3 of 8
3wood
in reply to: RChalmers2

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)
)

 

Message 4 of 8
Kent1Cooper
in reply to: RChalmers2

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.]

Kent Cooper, AIA
Message 5 of 8
RChalmers2
in reply to: hgasty1001

Works! Thanks.
Message 6 of 8
RChalmers2
in reply to: 3wood

What is the command?
Message 7 of 8
RChalmers2
in reply to: Kent1Cooper

I'm not a coder. Can you explain this?
Thanks
Message 8 of 8
RChalmers2
in reply to: 3wood

I figured out the command. Works great! Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost