如果dwg中存在图层MyLayer,则会收到错误。您最好这样使用smth:
- (defun create-my-layer (name ltype color / res)
- ;|
- * Creates a new layer in current dwg.
- * If layer exist, returns an ename-pointer to it (no changes). If not, layer
- * has been tried to create with settings.
- * Call parameters:
- name Name of layer
- ltype Name of linetype setted to created layer. If it doesn't exist
- the linetype "Continuous" will be used
- color ICA-color for creating layer
- |;
- (cond
- ((tblobjname "layer" "name"))
- (t
- (setq res (entmakex (list (cons 0 "LAYER")
- (cons 100 "AcDbSymbolTableRecord")
- (cons 100 "AcDbLayerTableRecord")
- (cons 2 name)
- (cons 6
- (cond ((tblobjname "ltype" ltype))
- (t "Continuous")
- ) ;_ end of cond
- ) ;_ end of cons
- (cons 62 color)
- ) ;_ end of list
- ) ;_ end of entmakex
- ) ;_ end of setq
- )
- ) ;_ end of cond
- ) ;_ end of defun
|