rodrigo_sjc_sp 发表于 2022-7-6 07:06:12

使用配色系统更改颜色

我使用此命令更改颜色(在层中)
(命令“_-layer”“\u m”layer“c”color\u selected“”)
 
 
 
如果选择的color_是索引,则样本。。。。。(1) 或(144)或(125)可以。
 
 
 
 
如何更改此突击队以接受配色系统?

MSasu 发表于 2022-7-6 07:13:01

根据这一点,似乎你需要输入可用的颜色书的名称。

Lee Mac 发表于 2022-7-6 07:18:07

下面是一个示例:
 

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

rodrigo_sjc_sp 发表于 2022-7-6 07:24:10

lisp显示此错误
 
eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
输入新层的名称(成为当前层):SAC。INF输入一个
选项
[?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre
eze/Thaw/LOck/Unlock/stAte/Description/rEconcile:c
新颜色:DIC color GUIDE®$DIC 10
需要颜色编号或标准颜色名称。
; 错误:功能已取消

rodrigo_sjc_sp 发表于 2022-7-6 07:33:19

李,
 
您的代码集调色板在哪里?
 
 
示例:
DIC COLOR GUIDE®$DIC 10

Lee Mac 发表于 2022-7-6 07:35:22

 
研究acad_truecolordlg函数(我的代码中的颜色变量)的返回,你会很快找到答案

rodrigo_sjc_sp 发表于 2022-7-6 07:39:19


 
无法自定义此命令
(命令“_-layer”“\u m”layer“c”color\u selected“”)
 
让他接受彩色书?

Lee Mac 发表于 2022-7-6 07:48:52

 
是的,看我上面的例子。。。

rodrigo_sjc_sp 发表于 2022-7-6 07:51:08


 
你能给我一个这个调用的例子吗?(defun c:示例(/颜色索引层值))
是否通过图层(LayerX)和调色板(DIC color GUIDE®DIC$10)?
 
样品
(定义c:示例(/DIC COLOR GUIDE®DIC$10索引(?)LayerX值(?)
 
我不了解参数和索引值。

Lee Mac 发表于 2022-7-6 07:59:33

我建议您一次编写一个表达式的代码,并确保您知道每个表达式返回的是什么,即首先独立评估acad\U truecolordlg表达式,并查看当您从配色系统中选择颜色时它返回的是什么;然后计算表达式(setq值(cdr(assoc 430 color)))以查看值变量包含的值,等等。
 
通过这个过程,你可以完整地理解程序。
页: [1] 2
查看完整版本: 使用配色系统更改颜色