Jump to content

Recommended Posts

Posted

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 ?

Posted

According to this, seems that you need to input the name of available colors book.

Posted (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 by Lee Mac
Posted

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

Posted

Lee ,

 

Where are you in your code sets the color palette?

 

 

Sample:

DIC COLOR GUIDE®$DIC 10

Posted
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 ;)

Posted

Lee

 

There is no way to customize this command

(command "_-layer" "_m" layer "c " color_selected "" "")

 

for him to accept Color Book?

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

Posted

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.

Posted

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.

Posted

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)

Posted

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;)

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