BLOACH85 Posted April 1, 2009 Posted April 1, 2009 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? Quote
Lee Mac Posted April 1, 2009 Posted April 1, 2009 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 ) Quote
Lee Mac Posted April 1, 2009 Posted April 1, 2009 Actually, probably needs an IF statement: (defun c:a1 () (if (cadr (ssgetfirst)) (command "_chprop" (cadr (ssgetfirst)) "" "_C" "1" "")) (princ)) Quote
BLOACH85 Posted April 1, 2009 Author Posted April 1, 2009 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. Quote
Lee Mac Posted April 1, 2009 Posted April 1, 2009 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)) Quote
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.