Jump to content

Hello freinds


motee-z

Recommended Posts

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 by motee-z
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

(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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...