
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I am pretty new to Visual LISP and this is my first post, but I've been reading alot on this forum to help me on my way. I'm not a big AutoCAD expert either, but I work with Revit alot and sometimes I just need to manipulate dwgs.
I made a script to delete all objects and layers I don't need for further use. It works, except that it also deletes some lines in layers I specified as where it shouldn't delete objects. I use the same phrasing to not delete those layers and that works perfectly. I even tried locking those layers, but that doesn't seem to help either. The only solution I can think of is to add another if statement on a higher level so it won't even consider the blocks on those layers, but I feel there has to be a more elegant solution.
Anyway, I hope someone has an answer for me! Here's the code I've been working on:
(vl-load-com) (defun c:extract-rooms nil (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) ; Make all layers visible and thawed (vlax-for layers1 (vla-get-layers aDoc) (vla-put-layeron layers1 :vlax-true) (if (not (eq (getvar 'CLAYER) (vla-get-name layers1))) (vla-put-freeze layers1 :vlax-false)) (if (wcmatch (vla-get-name layers1) "G_CR_PL$,G_RM_PL$") (vla-put-lock layers1 :vlax-true))) (princ) ; Delete all objects on all layers in all viewports except for the ones specified (vlax-for blocks (vla-get-blocks aDoc) (if (= :vlax-false (vla-get-isxref blocks)) (vlax-for object blocks (if (not (wcmatch (vla-get-layer object) "G_CR_PL$,G_CR_PL$TXT,G_RM_PL$,G_RM_PL$TXT")) (vla-delete object))))) (princ) ; Delete all layers except for the ones specified (vlax-for layers2 (vla-get-layers aDoc) (if (not (wcmatch (vla-get-name layers2) "0,G_CR_PL$,G_CR_PL$TXT,G_RM_PL$,G_RM_PL$TXT")) (vla-delete layers2) (vla-put-lock layers2 :vlax-false))) (princ) ) (princ)
Solved! Go to Solution.