rodrigo_sjc_sp Posted January 9, 2013 Posted January 9, 2013 I use this command to change the color ( in layers) (command "_-layer" "_m" layer "c " color_selected "" "") If color_selected is index ,, sample .....(1) or (144) or (125) is ok. How to change this commando to accept Color Book ? Quote
MSasu Posted January 9, 2013 Posted January 9, 2013 According to this, seems that you need to input the name of available colors book. Quote
Lee Mac Posted January 9, 2013 Posted January 9, 2013 (edited) Here is an example: (defun c:example ( / color index layer value ) (while (and (/= "" (setq layer (getstring t "\nSpecify Layer Name: "))) (or (not (snvalid layer)) (tblsearch "LAYER" layer) ) ) (princ "\nLayer invalid or already exists.") ) (if (and (/= "" layer) (setq color (acad_truecolordlg '(62 . 7) nil))) (progn (command "_.-layer" "_M" layer "_C") (cond ( (setq value (cdr (assoc 430 color))) (setq index (vl-string-position 36 value)) (command "_CO" (substr value 1 index) (substr value (+ index 2)) "" "") ) ( (setq value (cdr (assoc 420 color))) (command "_T" (substr (apply 'strcat (mapcar '(lambda ( x ) (strcat "," (itoa x))) (LM:True->RGB value)) ) 2 ) "" "" ) ) ( (setq value (cdr (assoc 62 color))) (command value "" "") ) ) ) ) (princ) ) ;; True -> RGB - Lee Mac 2011 ;; Args: c - True Colour (defun LM:True->RGB ( c ) (list (lsh (lsh (fix c) -24) (lsh (lsh (fix c) 16) -24) (lsh (lsh (fix c) 24) -24) ) ) (princ) Edited July 3, 2019 by Lee Mac Quote
rodrigo_sjc_sp Posted January 9, 2013 Author Posted January 9, 2013 The lisp show this error eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _m Enter name for new layer (becomes the current layer) : SAC.INF Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: c New color [Truecolor/COlorbook] : DIC COLOR GUIDE®$DIC 10 A color number or standard color name is required. ; error: Function cancelled Quote
rodrigo_sjc_sp Posted January 9, 2013 Author Posted January 9, 2013 Lee , Where are you in your code sets the color palette? Sample: DIC COLOR GUIDE®$DIC 10 Quote
Lee Mac Posted January 9, 2013 Posted January 9, 2013 Where are you in your code sets the color palette? Study the return of the acad_truecolordlg function (color variable in my code) and you'll quickly work it out Quote
rodrigo_sjc_sp Posted January 9, 2013 Author Posted January 9, 2013 Lee There is no way to customize this command (command "_-layer" "_m" layer "c " color_selected "" "") for him to accept Color Book? Quote
Lee Mac Posted January 9, 2013 Posted January 9, 2013 Lee There is no way to customize this command (command "_-layer" "_m" layer "c " color_selected "" "") for him to accept Color Book? Yes, see my example above... Quote
rodrigo_sjc_sp Posted January 9, 2013 Author Posted January 9, 2013 Lee Can you give me an example of this call ((defun c:example ( / color index layer value )) comparametro passing the layer (LayerX) and color palette (DIC COLOR GUIDE ® DIC $ 10)? Sample (defun c:example ( / DIC COLOR GUIDE ® DIC $ 10 index(?) LayerX value(?) ) I do not understand the parameters and index value. Quote
Lee Mac Posted January 9, 2013 Posted January 9, 2013 I recommend that you step through the code one expression at a time and ensure that you know what each expression is returning, i.e. first evaluate the acad_truecolordlg expression independently and see what it returns when you select a colour from a colour book; then evaluate the expression (setq value (cdr (assoc 430 color))) to see what value the value variable holds, etc. Through this process you can understand the program in its entirety. Quote
rodrigo_sjc_sp Posted January 9, 2013 Author Posted January 9, 2013 The final code I create this function to create a new layer and set color (COLOR BOOK) (defun c:create_layer_default() (setq layer "aaaa") (setq cor "DIC COLOR GUIDE(R)$DIC 6") (command "_.-layer" "_M" layer "_C") (cond ( ;;;(setq value (cdr (assoc 430 color))) (setq value cor) (setq index (vl-string-position 36 value)) (command "_CO" (substr value 1 index) (substr value (+ index 2)) "" "") ) ( (setq value (cdr (assoc 420 color))) (command "_T" (substr (apply 'strcat (mapcar '(lambda ( x ) (strcat "," (itoa x))) (LM:True->RGB value)) ) 2 ) "" "" ) ) ( (setq value (cdr (assoc 62 color))) (command value "" "") ) ) ) ;; True -> RGB - Lee Mac 2011 ;; Args: c - True Colour (defun LM:True->RGB ( c ) (list (lsh (lsh (fix c) -24) (lsh (lsh (fix c) 16) -24) (lsh (lsh (fix c) 24) -24) ) ) (princ) Quote
rodrigo_sjc_sp Posted January 9, 2013 Author Posted January 9, 2013 Thanks for Lee and All for the Help !. The code have 2 variables (setq layer "aaaa") = LAYER (setq cor "DIC COLOR GUIDE®$DIC 6") = COLOR BOOK I believe the code to work with truecolor, need to test, With Colorbook is ok;) 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.