motee-z Posted May 26, 2015 Share Posted May 26, 2015 (edited) Hello friends how we can get entity color even it is bylayer i use this syntax (setq e (car(entsel"\select entity>... "))) (setq objcolor (vla-get-Color (vlax-ename->vla-object e))) if the entity bylayer i got color value 256 whatever the color is Edited May 26, 2015 by motee-z Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 26, 2015 Share Posted May 26, 2015 Quick example: (defun entcolor ( enx ) (cond ((cdr (assoc 62 enx))) ((abs (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 enx))))))) ) ) Call with DXF data, e.g.: (if (setq ent (car (entsel))) (entcolor (entget ent)) ) Quote Link to comment Share on other sites More sharing options...
motee-z Posted May 26, 2015 Author Share Posted May 26, 2015 something going wrong Lee i got a message when getting value entcolor # what i want is to pick polyline or line then get its color store the color in a variable to use it later Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 26, 2015 Share Posted May 26, 2015 How are you calling the function? How are you using the value returned by the function? Quote Link to comment Share on other sites More sharing options...
motee-z Posted May 27, 2015 Author Share Posted May 27, 2015 (defun c:gcolr (/) (defun objco ( enx ) (cond ((cdr (assoc 62 enx))) ((abs (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 enx))))))) ) ) (if (setq e (car (entsel"\n pick polyline,line"))) (objco (entget e)) ) ) where is the color value stored Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 27, 2015 Share Posted May 27, 2015 (defun c:gcolr (/) (defun objco ( enx ) (cond ((cdr (assoc 62 enx))) ((abs (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 enx))))))) ) ) (if (setq e (car (entsel"\n pick polyline,line"))) (objco (entget e)) ) ) where is the color value stored With your current code the colour value is not stored, as you are not using the value returned by the 'objco' function. Consider the following: (defun c:gcolr ( / c e ) (if (setq e (car (entsel))) (setq c (objco (entget e))) ) (if c (princ (strcat "\nThe colour of the selected object is: " (itoa c))) (princ "\nThe user did not select an object.") ) (princ) ) (defun objco ( enx ) (cond ((cdr (assoc 62 enx))) ((abs (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 enx))))))) ) ) Quote Link to comment Share on other sites More sharing options...
motee-z Posted May 27, 2015 Author Share Posted May 27, 2015 thank Lee that,s okay Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 28, 2015 Share Posted May 28, 2015 You're welcome. Quote Link to comment Share on other sites More sharing options...
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.