Heduanna Posted May 12, 2008 Posted May 12, 2008 Hello, all, I know ordinarily objects on frozen layers can't be purged - but what if that's all I want to get rid of? I've got tons of frozen layers that all have to be purged out, and if I just unfreeze them all - I'll lose track! Is there any quick and easy way to tell CAD to just purge everything I can't see? (Or perhaps there's a way to flip the layer states?) Any ideas? Thanks so much! Heduanna Quote
fuccaro Posted May 12, 2008 Posted May 12, 2008 How about copy/paste what you see on the screen into a new drawing? Or zoom to extents, start the WBLOCK command and when prompted to "select objects" make a windows selection for the whole screen. Quote
Heduanna Posted May 12, 2008 Author Posted May 12, 2008 KISS - you're absolutely right! Thanks! Quote
alanjt Posted May 12, 2008 Posted May 12, 2008 this will delete and purge all frozen layers ;delete all frozen layers (defun c:delfrz (/ lays lay layname ss index lock_state) (command "undo" "begin") (setq lays (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)) ) ) (vlax-for lay lays (if (eq (vla-get-freeze lay) :vlax-true) (progn (setq layname (vla-get-name lay)) (if (not (wcmatch layname "*|*")) (progn (if (setq ss (ssget "_X" (list (cons 8 layname)))) (progn (vla-put-freeze lay :vlax-false) ;; NOT NEEDED (vla-put-layeron lay :vlax-true) (setq lock_state (vla-get-lock lay)) (vla-put-lock lay :vlax-false) ;; NOT NEEDED (vla-regen (vla-get-activedocument (vlax-get-acad-object))acactiveviewport) (setq index (sslength ss)) (while (>= (setq index (1- index)) 0) (vla-delete (vlax-ename->vla-object (ssname ss index))) (command "-layer" "t" layname "") (command "-purge" "la" layname "n") ) (if (eq lock_state :vlax-true) (vla-put-lock lay :vlax-true) ) ) (princ (strcat "Nothing on layer " layname)) ) ) (princ (strcat "Frozen or off xref layer skipped - " layname)) ) ) ) ) (command "undo" "end") (princ) ) Quote
Raggi_Thor Posted May 12, 2008 Posted May 12, 2008 How about copy/paste what you see on the screen into a new drawing? Or zoom to extents, start the WBLOCK command and when prompted to "select objects" make a windows selection for the whole screen. With old drawings or drawings from other sources, I like this approach. You get rid of all objects you don't need and you can start with your own settings. Quote
hugo1099 Posted October 15, 2009 Posted October 15, 2009 I'm just getting into Scripts, and can't get this to work. I copied and pasted it into notepad, then saved it as a .SCR, and dropped it into the file. The script ran, and in the command line it left "(_> )" , when I hit enter, nothing happened, and all of my frozen objects were still there? Any suggestions this will delete and purge all frozen layers ;delete all frozen layers (defun c:delfrz (/ lays lay layname ss index lock_state) (command "undo" "begin") (setq lays (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)) ) ) (vlax-for lay lays (if (eq (vla-get-freeze lay) :vlax-true) (progn (setq layname (vla-get-name lay)) (if (not (wcmatch layname "*|*")) (progn (if (setq ss (ssget "_X" (list (cons 8 layname)))) (progn (vla-put-freeze lay :vlax-false) ;; NOT NEEDED (vla-put-layeron lay :vlax-true) (setq lock_state (vla-get-lock lay)) (vla-put-lock lay :vlax-false) ;; NOT NEEDED (vla-regen (vla-get-activedocument (vlax-get-acad-object))acactiveviewport) (setq index (sslength ss)) (while (>= (setq index (1- index)) 0) (vla-delete (vlax-ename->vla-object (ssname ss index))) (command "-layer" "t" layname "") (command "-purge" "la" layname "n") ) (if (eq lock_state :vlax-true) (vla-put-lock lay :vlax-true) ) ) (princ (strcat "Nothing on layer " layname)) ) ) (princ (strcat "Frozen or off xref layer skipped - " layname)) ) ) ) ) (command "undo" "end") (princ) ) Quote
alanjt Posted October 15, 2009 Posted October 15, 2009 I'm just getting into Scripts, and can't get this to work. I copied and pasted it into notepad, then saved it as a .SCR, and dropped it into the file. The script ran, and in the command line it left "(_> )" , when I hit enter, nothing happened, and all of my frozen objects were still there? Any suggestions I think you just missed a paren when you were copy/pasting. However, give this one a try, should yield much better results... ;;; Delete frozen layers ;;; Alan J. Thompson, 10.15.09 (defun c:DelFrz (/ #Doc #SS) (vl-load-com) (vlax-for x (vla-get-layers (setq #Doc (vla-get-activedocument (vlax-get-acad-object)))) (if (and (eq (vla-get-freeze x) :vlax-true) (not (wcmatch (vla-get-name x) "*|*")) ) ;_ and (progn (vla-put-freeze x :vlax-false) (vla-put-lock x :vlax-false) (if (setq #SS (ssget "_X" (list (cons 8 (vla-get-name x))))) (progn (vlax-for i (setq #SS (vla-get-activeselectionset #Doc)) (vl-catch-all-apply 'vla-delete (list i)) ) ;_ vlax-for (vla-delete #SS) ) ;_ progn ) ;_ if (vl-catch-all-apply 'vla-delete (list x)) ) ;_ progn ) ;_ if ) ;_ vlax-for (princ) ) ;_ defun Quote
hugo1099 Posted October 15, 2009 Posted October 15, 2009 Same thing. I'm gonna do more research on Scripts before wasting anyones time, I'll post again if i'm still having trouble Thanks I think you just missed a paren when you were copy/pasting.However, give this one a try, should yield much better results... ;;; Delete frozen layers ;;; Alan J. Thompson, 10.15.09 (defun c:DelFrz (/ #Doc #SS) (vl-load-com) (vlax-for x (vla-get-layers (setq #Doc (vla-get-activedocument (vlax-get-acad-object)))) (if (and (eq (vla-get-freeze x) :vlax-true) (not (wcmatch (vla-get-name x) "*|*")) ) ;_ and (progn (vla-put-freeze x :vlax-false) (vla-put-lock x :vlax-false) (if (setq #SS (ssget "_X" (list (cons 8 (vla-get-name x))))) (progn (vlax-for i (setq #SS (vla-get-activeselectionset #Doc)) (vl-catch-all-apply 'vla-delete (list i)) ) ;_ vlax-for (vla-delete #SS) ) ;_ progn ) ;_ if (vl-catch-all-apply 'vla-delete (list x)) ) ;_ progn ) ;_ if ) ;_ vlax-for (princ) ) ;_ defun Quote
alanjt Posted October 15, 2009 Posted October 15, 2009 Same thing. I'm gonna do more research on Scripts before wasting anyones time, I'll post again if i'm still having trouble Thanks Post your script. You could just place the routine in a support path put this in your script: (and (load "Delfrz.lsp" nil) (c:DelFrz)) Quote
hugo1099 Posted October 15, 2009 Posted October 15, 2009 I've attached the txt file and the scr file Post your script.You could just place the routine in a support path put this in your script: (and (load "Delfrz.lsp" nil) (c:DelFrz)) purge frozen layers2.scr purge frozen layers2.txt Quote
alanjt Posted October 15, 2009 Posted October 15, 2009 I've attached the txt file and the scr file Try something like this: (defun DelFrz (/ #Doc #SS) (vl-load-com) (vlax-for x (vla-get-layers (setq #Doc (vla-get-activedocument (vlax-get-acad-object)))) (if (and (eq (vla-get-freeze x) :vlax-true) (not (wcmatch (vla-get-name x) "*|*")) ) ;_ and (progn (vla-put-freeze x :vlax-false) (vla-put-lock x :vlax-false) (if (setq #SS (ssget "_X" (list (cons 8 (vla-get-name x))))) (progn (vlax-for i (setq #SS (vla-get-activeselectionset #Doc)) (vl-catch-all-apply 'vla-delete (list i)) ) ;_ vlax-for (vla-delete #SS) ) ;_ progn ) ;_ if (vl-catch-all-apply 'vla-delete (list x)) ) ;_ progn ) ;_ if ) ;_ vlax-for (princ) ) (DelFrz) I'm confused though, why are you executing it as a script if that's all there is. This is a lisp routine. Quote
chelsea1307 Posted October 15, 2009 Posted October 15, 2009 You need to save it as a .lsp not a .scr and then load it and execute by DELFRZ Quote
alanjt Posted October 15, 2009 Posted October 15, 2009 You need to save it as a .lsp not a .scr and then load it and execute by DELFRZ If this is all you are trying to accomplish, just take the one I posted http://www.cadtutor.net/forum/showpost.php?p=276286&postcount=7 and save it just as Chelsea said. Quote
hugo1099 Posted October 15, 2009 Posted October 15, 2009 Sounds like I need to do much more research, this is all new to me. Thanks for all of your help Quote
alanjt Posted October 15, 2009 Posted October 15, 2009 Sounds like I need to do much more research, this is all new to me. Thanks for all of your help Ask all the questions you need. Review the FAQ section, it will give you a lot of the information you need. Quote
hugo1099 Posted October 15, 2009 Posted October 15, 2009 I've always been a standard construction guy turned CAD guy, I came across this site and finally reallized how much more I can be doing. I'll be asking very shortly. Thanks again Quote
alanjt Posted October 15, 2009 Posted October 15, 2009 I've always been a standard construction guy turned CAD guy, I came across this site and finally reallized how much more I can be doing. I'll be asking very shortly. Thanks again No problem. Quote
hugo1099 Posted October 16, 2009 Posted October 16, 2009 Got one for ya. I've been trying to string together a bunch of different commands for a Script, if I am doing a function, such as LINE, that keeps going until you hit cancel. How do I cancel it in my text file so I can begin another type of command? I've tried a number of commands, esc, cancel... Any suggestions? Quote
chelsea1307 Posted October 16, 2009 Posted October 16, 2009 you should start a new thread with a new question, you will get more views that way and a faster answer. I dont write scripts but you can end the line command with enter Quote
alanjt Posted October 16, 2009 Posted October 16, 2009 Got one for ya. I've been trying to string together a bunch of different commands for a Script, if I am doing a function, such as LINE, that keeps going until you hit cancel. How do I cancel it in my text file so I can begin another type of command? I've tried a number of commands, esc, cancel... Any suggestions? These are Lisps not Scripts. Give this a try: (defun c:test (/) (command "_.line") (while (not (zerop (getvar "cmdactive"))) (command PAUSE) ) ;_ while (princ) ) ;_ defun 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.