Tripledot 发表于 2022-7-5 17:34:44

color chan遇到错误

一直在使用这个变色lisp。到目前为止还不错。但发现有些行不会改变&反而会遇到错误。
 
 
附件为图纸。线路左侧无法更改。右侧can
 
问题是什么?
 
 
;;ColorCommandNames.lsp
;;Function name: CCN; command names 0 through 256
;;Defines commands for all color numbers.
;;Type color number as command, select objects, and
;;    they will have that color assigned as entity override.
;;Based on okc.lsp by Tommy Shumpert at Cadalyst CAD
;;    Tips, Tip #3645, "Change Entity Colors," 15 May 2011
;;Slightly altered, and expanded on, by Kent Cooper,
;;    13 September 2012, to add to original's colors 1-255:
;;    0 = ByBlock
;;    256 = ByLayer
;;Enhanced 17 September 2013 [prompt including color names,
;;    notifications, locked-Layer prevention, operation only with
;;    valid selection, command-echo suppression.]

(setq i 0)
(while (<= i 256)
(eval (read (strcat "(defun c:" (itoa i) "() (ccn " (itoa i) "))")))
(setq i (1+ i))
)

(defun ccn (color / ss cmde); = Color Command Name
(prompt
   (strcat
   "\nTo assign to object(s) color "
   (itoa color)
   (cond
       ((< color
         (strcat
         " ("
         (nth color '("ByBlock" "Red" "Yellow" "Green" "Cyan" "Blue" "Magenta" "White/Black"))
         ")"
         ); strcat
       ); ByBlock-or-named-color condition
       ((= color 256) " (ByLayer)")
       (""); add nothing for 1 through 255
   ); cond
   ","
   ); strcat
); prompt
(if (setq ss (ssget "_:L")); User selection, excluding object(s) on locked Layer(s)
   (progn ; then
   (setq cmde (getvar 'cmdecho))
   (setvar 'cmdecho 0)
   (command
       "._change" ss "" "p" "c"
       (cond
         ((= color 0) "byblock")
         ((= color 256) "bylayer")
         (color)
       ); cond
       ""
   ); command
   (setvar 'cmdecho cmde)
   (prompt (strcat "\nAssigned color to " (itoa (sslength ss)) " object(s)."))
   ); progn
   (prompt "\nNo changeable objects selected."); else
); if
(princ)
)

BKT 发表于 2022-7-5 17:43:13

插入该代码的哪个部分?

BIGAL 发表于 2022-7-5 17:47:39

 
可能,但不愿意。

Tripledot 发表于 2022-7-5 17:55:06

尝试更改:

(repeat (setq x (sslength ss))
(vla-put-color (vlax-ename->vla-object (ssname ss (setq x (- x 1)))) 4)
)

收件人:
"._change" ss "" "p" "c"

Tripledot 发表于 2022-7-5 17:58:10

 
谢谢你,伙计!!成功了!!

Roy_043 发表于 2022-7-5 18:07:23

尝试此功能
 
"._chprop" ss "" "c"

Tripledot 发表于 2022-7-5 18:09:29

 
尝试但当按下数字时,它不会注册命令。当按2或10,然后选择object&enter时,当前代码将把object更改为红色。如果按3或100,将变为绿色。

satishrajdev 发表于 2022-7-5 18:18:07

颜色2和10不相同。。。它们是相同颜色的不同色调。。。与3和100相同
 
你可以看到颜色指数的不同

Tripledot 发表于 2022-7-5 18:19:48

 
这是正确的。我指的是它在视觉上的底色。我想强调的是,颜色将根据您提到的颜色指数所指示的数字而变化。
 
顺便问一下,你的代码是如何工作的?

satishrajdev 发表于 2022-7-5 18:24:06

确实会改变物体的颜色。
页: [1] 2
查看完整版本: color chan遇到错误