Jump to content
Ament

Change color (RGB) of objects in a selection set

Recommended Posts

Ament

Hello together,

 

I thought I have a simple task to perform, but unfortunately it turned out to be more difficult than I expected:

 

I have in my lisp a code to select all elements in a drawing using (setq tbe (ssget "_X")), what I want to do now is to change the color of the selectionset to have a certain color. This color is defined by the RGB code 102,204,255.

 

Unfortunately I was not able to find the important hint to solve it by my own :(

 

Thank you for your help,

Ament

Share this post


Link to post
Share on other sites
ronjonp

Try this:

(defun c:foo (/ s)
 (if (setq s (ssget ":L"))
   (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     (entmod (append (entget e) '((420 . 6737151))))
   )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
Ament

Hi nahhphuc, unfortunately I'm a beginner in LISP and not able to identify the relevant code in the threat you mentioned :( Could you give me the hint?

Share this post


Link to post
Share on other sites
hanhphuc

http://www.lee-mac.com/runlisp.html

 

you can try copy the entire code by Ronjonp @ post#2 (shorter)

paste to command line

 

to invoke type,

command : foo

 

or

(c:foo)

Share this post


Link to post
Share on other sites
Grrr

Back then, when I was learning about grread: Grread + RGB (featuring the help of two giants).

Share this post


Link to post
Share on other sites
BIGAL

To convert the rgb use lee-mac function

 

;; RGB -> True  -  Lee Mac
;; Args: r,g,b - [int] Red, Green, Blue values
(defun LM:RGB->True ( r g b )
   (logior (lsh (fix r) 16) (lsh (fix g)  (fix b))
)

;(setq rgb (LM:RGB->True R G B))
(setq rgb (LM:RGB->True 102 204 255))
;6737151

Share this post


Link to post
Share on other sites
Ament

Wonderfull. It works just perfectly for me. Thanks again!

Share this post


Link to post
Share on other sites
Solitechcadsolutions

autocad chprop command would change the selected item color. is I am missing something ?

Share this post


Link to post
Share on other sites
rlx
autocad chprop command would change the selected item color. is I am missing something ?

 

 

yeah , you're missing all the fun of trying to use no command calls :D

Share this post


Link to post
Share on other sites
Solitechcadsolutions
:) haha big time learner here. i know only some functions of autolisp activex functions are like god for me i know its there but don't know how to use hahahaha (need your tips for better learning). thank you

Share this post


Link to post
Share on other sites
dlanorh
yeah , you're missing all the fun of trying to use no command calls :D

 

 

No, thats called Masochism. :lol:

Share this post


Link to post
Share on other sites
rlx
No, thats called Masochism. :lol:

 

 

my wife doesn't like commands too haha

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×