本帖最后由 lxf20190917 于 2024-2-18 12:49 编辑
下面说下二种更改线型的代码写法
一、常规的写法,先定义一个函数,再逐行写命令,从1~257。
演示方法一:
- ;定义函数 ($lxf:chang-color$ "bylayer")
- ;程序开始
- (defun $lxf:chang-color$ (color_number / ss)
- (setvar "cmdecho" 0)
- (setq ss (ssget))
- (while ss
- (if ss (progn(vl-cmdf "_.CHANGE" ss "" "PROPERTIES" "C" color_number "")
- (princ (strcat "\n *颜色改为<" color_number "> _BY 糯米88*"))
- (setq ss (ssget))))(princ)
- )
- (princ)
- )
快捷命令为1~257,可以根据自己习惯修改。 二、简易写法
- (DEFUN $dfg:lxf_numcolor$ (/ I X)
- (setq I 1)
- (REPEAT 257
- (cond ((= i 256)
- (progn (setq X
- (STRCAT "(defun c:"
- (ITOA I)
- "()(setvar "cmdecho" 0)(princ " "
- (STRCAT
- " 颜色改为< "
- "随层"
- " >号色 ")(if (setq ss (ssget))"
- "(vl-cmdf "change" ss "" "properties" "c" ""
- "bylayer"
- "" "")))"
- )
- "(princ)"
- )
- )
- (if X
- (PROGN (EVAL (READ X)))
- )
- )
- )
- ((= i 257)
- (progn (setq X
- (STRCAT "(defun c:"
- (ITOA I)
- "()(setvar "cmdecho" 0)(princ " "
- (STRCAT
- " 颜色改为< "
- "随层"
- " >号色 ")(if (setq ss (ssget))"
- "(vl-cmdf "change" ss "" "properties" "c" ""
- "Byblock"
- "" "")))"
- )
- "(princ)"
- )
- )
- (if X
- (PROGN (EVAL (READ X)))
- )
- )
- )
- (t
- (progn (setq X
- (STRCAT
- "(defun c:"
- (ITOA I)
- "()(setvar "cmdecho" 0)(princ " "
- (STRCAT " 颜色改为< "
- (ITOA I)
- " >号色 ")(if (setq ss (ssget))"
- "(vl-cmdf "change" ss "" "properties" "c" ""
- (ITOA I)
- "" "")))"
- )
- "(princ)"
- )
- )
- (if X
- (PROGN (EVAL (READ X)))
- )
- )
- )
- )
- (setq I (1+ I))
- )
- )
- (defun c:jzys();加载颜色 更改颜色快捷命令为1~257
- ($dfg:lxf_numcolor$))
|