Jump to content

Change Object Color


fade2blackened

Recommended Posts

Hi... :)

 

I have this lisp, made by me, which is pretty simple:

 

(defun C:CS ()
(command "change" "c" pause pause pause "p" "color" pause "")
)

:?

 

Well, it works "fine" if you know how to work with it...

You can only open one cross window (2 mouse "clicks").

 

This pause behavior is not I wanted first, but that's what worked for me... :wink:

 

 

Is there a way, so I can select as many objects as I want? :huh:

 

So, I select them, then I Enter, then I choose the color's number and then Enter again.

Something like that... :unsure:

 

Thanks for anyone who reads it! :)

Link to comment
Share on other sites

Here is the solution to your original question:

 

(defun c:cs ( / ss)
 (setq ss (ssget))
 (command "._change" ss "" "_P" "_C" pause "")
 (princ)
)

Here is a different approach. This defines a function for each color (1-255). So command 1 will change color to red, command 2 will change color to yellow, and so on.

 

(defun chco (color / ss1)
 (setq ss1 (ssget))
 (command "._change" ss1 "" "p" "c" color "" )
)
(setq i 1)
(while (<= i 254)
 (eval (read (strcat "(defun c:" (itoa i) (chr 40)(chr 41) "(chco " (itoa i) "))")))
 (setq i (1+ i))
)

Link to comment
Share on other sites

Hi rkmcswain,

 

Thanks for the solution! :D

The first lisp works perfectly! It was exactly what I was trying to do.

But when I tried to use the (setq ss (ssget)), I put it in a different way and it did not worked. :wink:

 

Thank you a lot!

Link to comment
Share on other sites

Try this:

(defun c:cc (/ usercol ss)
 (while (not (setq usercol (acad_colordlg 256))))
 (prompt "Select all object to change to one color.")
 (if (setq ss (ssget))
   (command "_.ChProp" ss "" "_C" usercol "")
 )
 (princ)
)

Link to comment
Share on other sites

  • 2 years later...
Try this:

(defun c:cc (/ usercol ss)
 (while (not (setq usercol (acad_colordlg 256))))
 (prompt "Select all object to change to one color.")
 (if (setq ss (ssget))
   (command "_.ChProp" ss "" "_C" usercol "")
 )
 (princ)
)

 

Fantastic CAB - as per usual.. :D

 

I had never heard of the acad_colordlg command... a very useful one indeed.

 

Would you say that you know just about all the LISP commands available to use by now? Or do you still come across some that you don't know?

 

Just Curious... :D

Link to comment
Share on other sites

I'm sure I have been exposed to all the LISP functions but without use they fade into deep memory which needs refreshing from time to time. I'm sure I have not seen all the visual lisp functions. The list is nearly endless. :)

 

You may find some intrest in this site http://www.kxcad.net/autodesk/autocad/

but it has some advertising hooks.

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