欢迎来到CADTutor
试试这个程序,别忘了更改图层的名称,以满足您的需要,以及颜色编号。
[未测试代码]
- (defun c:Test (/ name color doc sel)
- ;; Tharwat 17.12.2014 ;;
- (setq name "Layer" [color=blue];; <= Layer name [/color]
- color 1 [color=blue];; <= Color of layer[/color]
- doc (vla-get-activedocument (vlax-get-acad-object))
- )
- (if (not (tblsearch "LAYER" name))
- (entmake (list '(0 . "LAYER")
- '(100 . "AcDbSymbolTableRecord")
- '(100 . "AcDbLayerTableRecord")
- (cons 2 name)
- (cons 62 color)
- '(70 . 0)
- )
- )
- )
- (if (ssget "_X" '((0 . "HATCH")))
- (vlax-for x (setq sel (vla-get-ActiveSelectionSet doc))
- (if (vlax-write-enabled-p x)
- (vla-put-layer x name)
- )
- )
- )
- (if sel
- (vla-delete sel)
- )
- (repeat 3 (command "_.-purge" "a" "*" "n"))
- (princ)
- )
- (vl-load-com)
干杯 |