下面是一个示例:
- (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)
|