Jump to content
jonathann3891

Erase Layer/Object problem

Recommended Posts

jonathann3891

The code below is only supposed to delete the layers listed in the code but its also deleting layers that aren't listed. I even tested it on a drawing that didn't have the layers listed and it still deleted a bunch of layers, so I dont know what the issue is.

 

(defun c:demo  (/ aDoc name)
     (setvar 'Clayer "0")
     (repeat 4
           (vla-purgeall
                 (setq aDoc (vla-get-ActiveDocument
                                  (vlax-get-acad-object)))))
     (vlax-for
            itm
                 (vla-get-layers aDoc)
           (if (and
                     (not (wcmatch
                                (setq name (vla-get-name itm))
                                "*|*"))
                     (not (eq name "0"))
                     (member name
                                  '("3dTxtBmXe"
                                    "3dTxtBmXp"
                                    "3dTxtBmXp-LOCKED"
				    "3dTxtBmYe"
				    "3dTxtBmYp"
				    "3dTxtBmYp-LOCKED"
				    "3dTxtBrH"
				    "3dTxtBrVx"
				    "3dTxtBrVy"
				    "3dTxtColx"
				    "3dTxtColy")))
                 (progn
                       (vla-put-lock itm :vlax-false)
                       (vl-cmdf "_.-laydel" "_N" name "" "_Y"))
                 )
           )
     (repeat 4 (vla-purgeall aDoc))
     (princ)
     )

 

Share this post


Link to post
Share on other sites
Roy_043

Well you do call vla-purgeall...

Share this post


Link to post
Share on other sites
jonathann3891

You are completely right! It been a good while sense I've messed with lisp.

 

Thank you, Roy! Its working as it should now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×