Exchange Forum > AutoLISP and Visual LISP
Help Fix Isolate Layers!
Help Fix Isolate Layers!

#1

Theodorus Winata
Join Date:
11-15-2007
Hi Everybody,
 
Attached is ILA.lsp (Isolate Layers), it works with Acad 2004. Since I upgraded to Acad 2008, it doesn’t work.
Could you please take a look into it and tell me how to fix it? Thanks for your help.
 
Regards,
 
Theodorus Winata

Attachments  ILA.lsp  
Help Fix Isolate Layers!

#2

Terry Cadd
Join Date:
09-10-2007
Theodorus,
Sometimes it's easier for me just to write from scratch. Try this out. It should work on any version of AutoCAD.
Best regards,
Terry
Code:
(defun c:Isolate (/ Clayer$ Cnt# EntList@ Layer$ LayerList@ SS&)
  (princ "\nSelect object(s) on the layer(s) to be isolated: ")
  (if (setq SS& (ssget))
    (progn
      (setq Cnt# 0)
      (repeat (sslength SS&)
        (setq EntList@ (entget (ssname SS& Cnt#)))
        (setq Layer$ (cdr (assoc 8 EntList@)))
        (if (not (member Layer$ LayerList@))
          (setq LayerList@ (append LayerList@ (list Layer$)))
        );if
        (setq Cnt# (1+ Cnt#))
      );repeat
      (if (member (getvar "CLAYER") LayerList@)
        (setq Clayer$ (getvar "CLAYER"))
        (setvar "CLAYER" (setq Clayer$ (last LayerList@)))
      );if
      (setq Layer$ (cdr (assoc 2 (tblnext "LAYER" t))))
      (while Layer$
        (if (not (member Layer$ LayerList@))
          (command "LAYER" "OFF" Layer$ "")
        );if
        (if (setq Layer$ (tblnext "LAYER"))
          (setq Layer$ (cdr (assoc 2 Layer$)))
        );if
      );while
      (if (= (length LayerList@) 1)
        (princ (strcat "\nLayer " Clayer$ " has been isolated."))
        (princ (strcat "\n" (itoa (length LayerList@)) " layers have been isolated. Layer " Clayer$ " is current."))
      );if
    );progn
  );if
  (princ)
);defun c:Isolate
 
Help Fix Isolate Layers!

#3

Theodorus Winata
Join Date:
11-15-2007
Terry,
Your Isolate.lsp works. To turn back on layers after Isolate executed, I can use (Command “_.-LAYER” “_ON” “*” “”)!
Thanks for your great help, I really appreciate it.
 
Regards,
Theodorus