au-s Posted January 30, 2009 Posted January 30, 2009 I've got this: (defun c:ax:purge-layers (doc except) (vlax-for item (vla-get-layers doc) (setq ln (vla-get-name item)) (if (not (member (strcase ln) except)) (purge-layer ln) ) ) ) (defun c:DeleteLayerFilters () (vl-Catch-All-Apply '(lambda () (vla-Remove (vla-GetExtensionDictionary (vla-Get-Layers (vla-Get-ActiveDocument (vlax-Get-Acad-Object)) ) ) "ACAD_LAYERFILTERS" ) ) ) (princ) ) (defun c: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 () (command "_layer" "On" "0" "t" "0" "s" "0" "") (command "_purge" "a" "*" "n") (command "-purge" "r" "*" "n") (C:DeleteLayerFilters) (C:DeleteLayerFilters2) (c:ax:purge-layers) (if (= (getvar "tilemode") 1) (prompt "\nModel is purged.") (prompt "\nLayout is purged.") ) (princ) ) Its working but its not prompting and the error I get is: Command: "too few arguments" Thanx for help! Quote
VVA Posted January 30, 2009 Posted January 30, 2009 1. c:ax:purge-layers cannot be a command! this is a function (it have 2 arguments) 2. In this page I not found function purge-layer Try it (with little changes) ;;; 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) ) Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 The function (defun c:ax:purge-layers (doc except) requires two arguments, namely "doc" and "except". These need to be specified when calling the function. If the functions like the one above are to be called within another function, and not separately, why not specify them as local functions i.e. (defun ax:purge-layers... Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 Oooo VVA, just beat me there by a few minutes Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 why few? only one :wink: Well OK, only one then - I didn't look at the times that closely... my sincerest apologies. :oops::oops::oops: Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.