Author Topic: Deleting Frozen Layers  (Read 4209 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Deleting Frozen Layers
« on: November 09, 2004, 10:05:14 AM »
Does anyone have a lisp which will allow me to delete frozen layers?

I have to issue 50 bound drawings, but each drawing has all only 1 xref will all electrical services as per the clients request, but when I bind this XREF each bound drawing is ove 3 meg in size.

If i could delete the layers which are frozen off it would be great.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

ronjonp

  • Needs a day job
  • Posts: 7529
Deleting Frozen Layers
« Reply #1 on: November 09, 2004, 10:09:07 AM »
Code: [Select]
;;;   Deletes all objects on frozen (unlocked) layers
;;;   Then deletes the layer
;;;
;;;   04/06/2004 CAB modified to include unlock test & fixed bug.
;;;

(defun c:frzlaydel ()
  (vlax-for each (vla-get-layers (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (cond
      ((and
         (= (vla-get-freeze each) :vlax-true)
         (= (vla-get-lock each) :vlax-false);CBA
        )
       (foreach item
                     (ssget->vla-list
                       (ssget "x"
                              (list (cons 8 (vla-get-name each)))
                       )
                     )
         (vl-deleteobject item)
       )
       (vl-deleteobject each)
      )
    )
  )
)


;;;=====================================================================;
;;; SSGET->VLA-LIST                                                      ;
;;;---------------------------------------------------------------------;
;;;                                                                      ;
;;; This function converts a valid ACAD selction                         ;
;;; set to a list of vla-objects.                                        ;
;;;                                                                      ;
;;; Arguments: selection-list = a valid ACAD selection set               ;
;;;                             returned by ssget.                       ;
;;;                                                                      ;
;;; Returned Value:  A list of all circles as vla-objects                ;
;;;        such as:  (#<VLA-OBJECT IAcadCircle 01b4211c>                 ;
;;;                   #<VLA-OBJECT IAcadCircle 01b42790>                 ;
;;;                   #<VLA-OBJECT IAcadCircle 01b429a0>)                ;
;;;                                                                      ;
;;;Usage: (ssget->vla-list (ssget))                                      ;
;;;=====================================================================;
(defun ssget->vla-list (selection-set / index vla-list)
  (setq index (if selection-set
                (1- (sslength selection-set))
                -1
              )
  )
  (while (>= index 0)
    (setq vla-list
                   (cons
                     (vlax-ename->vla-object
                       (ssname selection-set index)
                     )
                     vla-list
                   )
          index    (1- index)
    )
  )
  vla-list
)


(defun vl-deleteobject (name)
  (cond
    ((and
       (not (vlax-erased-p name))
       (vlax-read-enabled-p name)
       (vlax-write-enabled-p name)
     )
     (vlax-invoke-method name 'delete)
     (if (not (vlax-object-released-p name))
       (vlax-release-object name)
     )
    )
    (t (princ "\n** Cannot delete object! **"))
  )
)


You also might want to try Keith's Endit lisp to reduce file size.



Here is one to freeze all off layers.
Code: [Select]


(defun C:layfrzoff( / lay layname laylist)
  (setq lay (tblnext "layer" t))
  (while lay
    (setq layname (cdr (assoc 2 lay)))
    (if (<(cdr (assoc 62 (tblsearch "layer" layname))) 0)
      (progn
        (setq laylist (entget (tblobjname "layer" (cdr (assoc 2 lay)))))
   (entmod (subst (cons 70 1) (assoc 70 laylist) laylist))
      )    
    )
    (setq lay (tblnext "layer"))
  )
)


HTH

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

AfricaAD

  • Guest
Deleting Frozen Layers
« Reply #2 on: November 09, 2004, 05:57:34 PM »
how about a lisp to turn off frozen layers?

CADaver

  • Guest
Deleting Frozen Layers
« Reply #3 on: November 09, 2004, 06:13:29 PM »
Quote from: AfricaAD
how about a lisp to turn off frozen layers?
ummm... huh?

CADaver

  • Guest
Re: Deleting Frozen Layers
« Reply #4 on: November 09, 2004, 06:17:02 PM »
Quote from: Hudster
Does anyone have a lisp which will allow me to delete frozen layers?

I have to issue 50 bound drawings, but each drawing has all only 1 xref will all electrical services as per the clients request, but when I bind this XREF each bound drawing is ove 3 meg in size.

If i could delete the layers which are frozen off it would be great.
Sounds like a reason not to bind to me, but there ya' go.  

Is it the same file or group of files XREF'd into them all?  If so think about saving the source XREF's to a safe location, then opening them up and deleting the appropriate layers prior to binding in the target file.  After binding, you can replace the original files from the previous "safe" location.

ML

  • Guest
Deleting Frozen Layers
« Reply #5 on: November 10, 2004, 06:59:26 AM »
A bit differen but I have a VBA Module that will lock all xref layers if anyone is interested? It can "very" easily be tweaked to freeze or turn off xref'd layers also.

Let me know and I will post it


Mark