;Lisp: XLTH.LSP ; ;;;Elise Moss ;;;www.mossdesigns.com ;;;December 2004 ; ;Function: User selects an xref and then freeze all layers in that xref that have a user set pattern in the name. ; ; THE AUTHOR PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. THE ; AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY ; OF FITNESS FOR A PARTICULAR USE. THE AUTHOR DOES NOT WARRANT THAT ; THE OPERATION OF THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE. ;;; --------------------------------------------------------------------------------- (defun c:xlth () ; first user must select an xref (prompt "\nSelect the xref to freeze layers: ") (setq xname (entsel)) (setq xname (car xname)) ;get data of selected object (setq xdata (entget xname)) (setq xdata-type (cdr (assoc 0 xdata))) (while (/= xdata-type "INSERT") ; then selected item was not an xref- user must reselect (progn (alert "Selected object was not an XREF - Please pick again." ) (setq xname (entsel)) (setq xname (car xname)) ;get data of selected object (setq xdata (entget xname)) (setq xdata-type (cdr (assoc 0 xdata))) ) ;end progn ) ; end while ; now we have an xref...let's look at the xref's name (setq xref-name (cdr (assoc 2 xdata))) ; now we can look at all the layers associated with that xref (setq pattern (strcat xref-name "*")) (setq LST (tblnext "LAYER" T)) (setq lst-name (cdr (assoc 2 lst))) (while (/= lst nil) (if (wcmatch lst-name pattern) (setq xref-laylist (append xref-laylist (list lst-name))) ) ; end if (setq LST (tblnext "LAYER")) (setq lst-name (cdr (assoc 2 lst))) ) ; end while ;; we have now created a list of all the layers associated with that xref ;;;we want to freeze any layers that have patt2 in them ; get the number of layers in the list (setq laynum (length xref-laylist)) (setq index 0) ; create a counter ;;prompt for pattern (setq patt2 (getstring "\nEnter layer name filter to use for freeze: ") ) (setq patt2 (strcat "*" patt2 "*")) (while (< index laynum) ; get a layer in the list (setq layname (nth index xref-laylist)) ; check to see if this layer has the pattern in it (setq flag (wcmatch layname patt2)) ; if flag is T, then freeze the layer (if (= flag T) (command "-layer" "f" layname "") ) ;end if ; go on to the next layer name (setq index (1+ index)) ) ;end while ) (princ "\nType 'xlth' to freeze layers in an xref.")