1.c:ax:purge layers不能是命令!这是一个函数(它有2个参数)
2.在本页中,我没有找到功能清除层
试试看(稍作改动)
- ;;; Purge named layer
- ;;; Example: (ax:purge-layer (vla-get-activedocument (vlax-get-acad-object)) "testlayer")
- ;;; Argument: doc {document}
- ;;; name {a layer name}
- ;;; Return values: T if successful, nil if not successful
- (defun ax:purge-layer (doc name)
- (if (vl-catch-all-error-p
- (vl-catch-all-apply
- 'vla-delete
- (list (vl-catch-all-apply
- 'vla-item
- (list (vla-get-layers doc) name)
- )
- )
- )
- )
- nil ; name cannot be purged or doesn't exist
- T ; name purged
- )
- )
- ;;; Purge all layers
- ;;; Example: (ax:purge-all-layers (vla-get-activedocument (vlax-get-acad-object
- ;;; Argument: doc {document}
- (defun ax:purge-all-layers (doc)
- (vlax-for item (vla-get-layers doc)
- (ax:purge-layer doc (vla-get-name item))
- )
- )
- (defun DeleteLayerFilters ()
- (vl-Catch-All-Apply
- '(lambda ()
- (vla-Remove
- (vla-GetExtensionDictionary
- (vla-Get-Layers
- (vla-Get-ActiveDocument (vlax-Get-Acad-Object))
- )
- )
- "ACAD_LAYERFILTERS"
- )
- )
- )
- (princ)
- )
- (defun DeleteLayerFilters2 ()
- (vl-Catch-All-Apply
- '(lambda ()
- (vla-Remove
- (vla-GetExtensionDictionary
- (vla-Get-Layers
- (vla-Get-ActiveDocument (vlax-Get-Acad-Object))
- )
- )
- "AcLyDictionary"
- )
- )
- )
- (princ)
- )
- (defun c:test ()
- (vl-load-com)
- (command "_layer" "_On" "0" "_t" "0" "_s" "0" "")
- ;;;(command "_-purge" "_a" "*" "_n")
- (repeat 3 (vla-purgeall (vla-get-activedocument (vlax-get-acad-object))))
- (command "_-purge" "_r" "*" "_n")
- (DeleteLayerFilters)
- (DeleteLayerFilters2)
- (ax:purge-all-layers (vla-get-activedocument (vlax-get-acad-object)))
- (if (= (getvar "tilemode") 1)
- (alert "Model is purged.")
- (alert "Layout is purged.")
- )
- (princ)
- )
|