delete all freeze and off layer

delete all freeze and off layer

michaelZCXYL
Enthusiast Enthusiast
3,817 Views
9 Replies
Message 1 of 10

delete all freeze and off layer

michaelZCXYL
Enthusiast
Enthusiast

Hello,

 

I am wondering if there is way to delete all freeze and off layer, many thanks. 🙂

0 Likes
Accepted solutions (1)
3,818 Views
9 Replies
Replies (9)
Message 2 of 10

chriscowgill7373
Mentor
Mentor

Delete all frozen and off layers?  You could use the LAYDEL command (just create a (command) with the proper prompts answered), but typically deleting layers that have objects on them can cause corruption.   So you might want to delete all those entities first.


Christopher T. Cowgill, P.E.

AutoCAD Certified Professional
Civil 3D Certified Professional
Civil 3D 2026 on Windows 11

Please select the Accept as Solution button if my post solves your issue or answers your question.

0 Likes
Message 3 of 10

ronjonp
Mentor
Mentor
Accepted solution

@michaelZCXYL 

I use this almost daily:

(defun c:frzlaydel (/ d er fl n n2)
  ;; RJP » 2020-08-05
  (mapcar 'set '(er n n2) '(0 0 0))
  ;; Get frozen and off layers
  (vlax-for lay	(vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
    (and (not (wcmatch (strcase (vla-get-name lay)) "*|*,0,DEFPOINTS"))
	 (or (= -1 (vlax-get lay 'freeze)) (= 0 (vlax-get lay 'layeron)))
	 (setq fl (cons (vla-get-name lay) fl))
	 (vlax-put lay 'lock 0)
    )
  )
  (if fl
    (progn (vlax-for b1	(vla-get-blocks d)
	     ;; If it's not an xref
	     (if (= 0 (vlax-get b1 'isxref))
	       (vlax-for b2 b1
		 (if (vl-position (vla-get-layer b2) fl)
		   (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list b2)))
		     (setq er (1+ er))
		     (setq n (1+ n))
		   )
		   (setq n2 (1+ n2))
		 )
	       )
	     )
	   )
	   (repeat 3 (vla-purgeall d))
	   (princ (strcat (itoa er)
			  " errors deleting objects...\n"
			  (itoa n)
			  " objects were deleted, "
			  (itoa n2)
			  " objects were ignored."
		  )
	   )
    )
    (princ (strcat "\nNo eligible layers found."))
  )
  (princ)
)
Message 4 of 10

ВeekeeCZ
Consultant
Consultant

Could be handy. But... a bit too powerful for my taste. I would probably add the option to save objects inside blocks. These objects are difficult to acknowledge. 

0 Likes
Message 5 of 10

ronjonp
Mentor
Mentor

@ВeekeeCZ Yeah it's a bit brute force but I use this for my bases from clients to slim them up as much as possible 🙂

0 Likes
Message 6 of 10

pendean
Community Legend
Community Legend
@ronjonp I like it (quick test here on a couple of files, I could use this occasionally to send files to others): safety off folks, user beware!!!!
0 Likes
Message 7 of 10

ronjonp
Mentor
Mentor

@pendean Thanks!

It's been very helpful for me. I couple it with code to change certain layer colors and force everything to bylayer then super purge and close. 😎

On average after I 'clean' a base it's reduced in file size over 50%-90%.

0 Likes
Message 8 of 10

michaelZCXYL
Enthusiast
Enthusiast

Hello,

@ronjonp Great Job ! 🙂

Thank you very much all of you!

0 Likes
Message 9 of 10

rkalachov6AB4Y
Observer
Observer

It worked for me, thank you

0 Likes
Message 10 of 10

ronjonp
Mentor
Mentor

You're welcome! : )

0 Likes