Jump to content

Recommended Posts

Posted

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

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    9

  • hugo1099

    6

  • Heduanna

    2

  • chelsea1307

    2

Top Posters In This Topic

Posted

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.

Posted

KISS - you're absolutely right! Thanks!

Posted

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)
)

Posted
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.

  • 1 year later...
Posted

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)
)

Posted
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

Posted

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

Posted
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))

Posted
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.

Posted

You need to save it as a .lsp not a .scr and then load it and execute by DELFRZ

Posted

Sounds like I need to do much more research, this is all new to me. Thanks for all of your help

Posted
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.

Posted

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

Posted
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.

Posted

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?

Posted

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

Posted
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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...