Jump to content

Question about colors


BLOACH85

Recommended Posts

Hey i threw together this simple lisp routine that just changes the color of you specific layer ex. LAYER=STEEL COLOR=YELLOW it will change it to LAYER=STEEL COLOR=RED or COLOR=COLOR 10. But here is my issue, I also want to be able to select any object and then pick my color toolbar (that i made to go with the lisp) and change the object to that color or even linetype for that matter without having to go up to the lt toolbar or the color toolbar. I will post the code below.

 

(defun c:a1 (/ *error*);red
  (defun *error* (msg)
   (and Osmode# (setvar "osmode" Osmode#))
   (command "_.undo" "_e")
   (if
   (not
   (member
     msg
   '("console break" "Function cancelled" "quit / exit abort")
   ) ;_ member
   ) ;_ not
            (princ (strcat "\nError: " msg))
   ) ;_ if
   ) ;_ defun
 '(command "color" 1)
 (princ)
 )

 

See, its just a simple command manipulation with an error routine with it. (just in case) If anyone knows how to do this let me now.

 

(the purpose of this routine is because we are on a color dependent plot style so our line thickness is set on our colors and instead of creating 20 diff. layers why not create a few and just change the colors?

Link to comment
Share on other sites

Not sure quite what you are after, but something like this for selecting an entity and changing its colour:

 

(defun c:a1 ()
 (command "_chprop" (cadr (ssgetfirst)) "" "_C" "1" "")
 (princ))

 

( no need for error trap )

Link to comment
Share on other sites

Actually, probably needs an IF statement:

 

(defun c:a1 ()
 (if (cadr (ssgetfirst))
 (command "_chprop" (cadr (ssgetfirst)) "" "_C" "1" ""))
 (princ))

Link to comment
Share on other sites

Ok here is what i want i need it to just change the color of a specific layer and also change the color of a specific selected object. Both not either or.

Link to comment
Share on other sites

Maybe:

 

(defun c:a1 (/ ss col ent)
 (if (and (setq ss (ssget))
      (setq col (acad_colordlg 0 T)))
   (progn
     (setq ent (ssname ss 0))
     (command "-layer" "_C" col (cdr (assoc 8 (entget ent))) "")
     (command "_chprop" ss "" "_C" "BYLAYER" ""))
   (princ "\n<!> No Colour/Object Selected <!>"))
 (princ))

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