Here's a routine I found on the augi site that I can use.
It takes a selection set and puts them on new layers "*-FREEZE"
which are frozen. Nice, but I'd like to add a fuction to THAW them back to their original state (ie, put 'em back on their original layer), and delete the *-FREEZE layer if nothing is on 'em.
Any takers? (credit to the swamp will go back to the author)
;;; Created by Karl Browning
;;; kbrowning@chasebrass.com
;;; 16 May 2003
;;;
;;; This function is used to select an object(s), figure out what layer it is on,
;;; make a new layer based on the old one with "-Freeze" appended, change the object
;;; to the new layer, then freeze layers *-Freeze. I made this to clean up some vendor
;;; prints without losing the data.
;;;
;;; Feel free to modify the lisp, just send me a copy of it when you are done. ;)
(defun c:FRZOBJ (/ sset counter item LayerName NewLayerName)
(vl-load-com)
(initerr) ;Load error trapping
(setvar "cmdecho" 0)
(command "undo" "m")
(setq sset (ssget)) ;get selection set
(setq counter 0) ;set the counter
(repeat (sslength sset) ;count number of entities and loop
(setq item (ssname sset counter) ;extract the entity name
item (vlax-ename->vla-object item)
;convert to a vl object
LayerName (vla-get-layer item) ;get the object's layer
) ;_ end of setq
(if (= (TBLSEARCH "Layer" (strcat LayerName "-Freeze")) nil)
;check for "layer"-Freeze
(progn
(setq NewLayerName (strcat LayerName "-Freeze"))
;if not there, create it
(command ".layer" "new" NewLayerName "")
) ;_ end of progn
(setq NewLayerName (strcat LayerName "-Freeze"))
) ;_ end of if
(vla-put-layer item NewLayerName)
(setq counter (1+ counter))
) ;_ end of repeat
(princ)
(command ".layer" "freeze" "*-Freeze" "")
(setq sset nil)
(reset)
(princ)
) ;_ end of defun
(defun error ()
(prompt "\nGlobal Error Trap Loaded")
(princ)
)
;;;*=================================================================================
(defun initerr ()
(setq oldlayer (getvar "clayer")
oldsnap (getvar "osmode")
oldpick (getvar "pickbox")
temperr *error*
*error* trap)
(princ)
)
;;;*=================================================================================
(defun trap (errmsg)
(command nil nil nil)
(if (not (member errmsg '("console break" "Function Cancelled"))
)
(princ (strcat "\nError: " errmsg))
)
(command "undo" "b")
(setvar "clayer" oldlayer)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(princ "\nError Resetting Environment ")
(terpri)
(setq *error* temperr)
(princ)
)
;;;*=================================================================================
(defun reset ()
(setq *error* temperr)
(setvar "clayer" oldlayer)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(princ)
)
;;;*=================================================================================
(princ)