level 6
(defun C:LayerCutByColor (/ entLst eLst sLayer sColor sLine sLayerName)
(setq entLst (entnext))
(while entLst ;存在图元
(setq eLst (entget entLst))
(setq sLayer (EF-GetCode 8 eLst)) ;获取图元图层名
(setq sColor (EF-GetCode 62 eLst))
(setq sLine (cdr (assoc 6 (tblsearch "Layer" sLayer))))
(if (and sColor (/= sColor 0))
(progn
(setq sLayerName (strcat sLayer "-" (rtos sColor)))
(if (tblsearch "LAYER" sLayerName) nil
(command "layer" "N" sLayerName "S" sLayerName "C" sColor sLayerName "L" sLine sLayerName "")
) ;无图层则创建图层
(setq eLst (subst (cons 8 sLayerName) (assoc 8 eLst) eLst))
(setq eLst (subst (cons 62 256) (assoc 62 eLst) eLst))
(setq eLst (ef-list-delitem (assoc 420 eLst) eLst))
(entmod eLst)
)
)
(setq entLst (entnext entLst))
)
)
(defun EF-GetCode (code elist)
(cdr (assoc code elist))
);end EF-GetCode
;删除列表 oldList 指定位置 iPos 后 n个元素
(defun ef-list-delete ( oldList iPos n / i )
2015年01月23日 08点01分