下边两个函数都可以以LAY为图层名建好图层(没有就建),把颜色改为CLR指定的颜色,把LAY指定的图层名置为当前图层
- (defun SETLAYER(LAY CLR / AcDocument layerObj)
- (vl-load-com)
- (setq layerObj(vla-add(vla-get-Layers(setq AcDocument(vla-get-ActiveDocument(vlax-get-acad-object))))LAY))
- (vla-put-ActiveLayer AcDocument layerObj)
- (vla-put-Color layerObj CLR)
- )
- (defun SETLAYER_LSP(LAY CLR)
- (if (=(tblobjname "LAYER" LAY) nil)
- (entmake (list'(0 . "LAYER")'(100 . "AcDbSymbolTableRecord")'(100 . "AcDbLayerTableRecord")
- '(6 . "CONTINUOUS")(cons 62 CLR)'(70 . 0)(cons 2 LAY)))
- (entmod(subst(cons 62 CLR)(assoc 62(entget(tblobjname "LAYER" LAY)))(entget(tblobjname "LAYER" LAY))))
- ) (setvar "CLAYER" LAY)
- )
|