一直在使用这个变色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)
- )
|