Author Topic: Isolate layer on an xref.. possible?  (Read 7890 times)

0 Members and 2 Guests are viewing this topic.

Robb

  • Guest
Re: Isolate layer on an xref.. possible?
« Reply #15 on: October 31, 2007, 08:21:14 PM »
Here's my rinky dink version:

Use NLAYUNISO to restore layer settings.

Code: [Select]
(defun dxf (x ename / llst)
  (cdr (assoc x (entget ename)))
)
(defun c:nlayiso (/ LAYS LLST X)
  (setq lays (vla-get-layers
       (vla-get-activedocument (vlax-get-acad-object))
     )
  )
  (if *frzlyrs*
    (c:nlayuniso)
  )
  (while (setq x (nentsel "\nSelect objects to isolate nested layers: "))
    (progn
      (setq llst (cons (dxf 8 (car x)) llst))
      (if (nth 3 x)
(foreach z (nth 3 x)
  (setq llst (cons (dxf 8 z) llst))
)
      )
    )
  )
  (if llst
    (progn
      (vlax-map-collection
lays
'(lambda (x)
   (if (not (member (vla-get-name x) llst))
     (progn
       (setq *frzlyrs*
      (append *frzlyrs* (list (cons x (vla-get-freeze x))))
       )
       (vl-catch-all-error-p
(vl-catch-all-apply
   'vla-put-freeze
   (list x :vlax-true)
)
       )
     )
   )
)
      )
      (defun c:nlayuniso (/)
(if *frzlyrs*
  (mapcar '(lambda (x)
     (vl-catch-all-error-p
       (vl-catch-all-apply
'vla-put-freeze
(list (car x) (cdr x))
       )
     )
   )
  *frzlyrs*
  )
)
(command "._regen")
(setq *frzlyrs* nil)
(princ)
      )
    )
  )
  (princ)
)

I'll try Ron, thanks!

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Isolate layer on an xref.. possible?
« Reply #16 on: October 31, 2007, 10:11:53 PM »
LAYOFF and LAYFRZ

That does the opposite of what he wants.
Misread the second half of his sentence.

es ok....happens to the best of us  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Isolate layer on an xref.. possible?
« Reply #17 on: February 08, 2015, 05:41:12 AM »
Another version of the same thing:
Code - Auto/Visual Lisp: [Select]
  1. (princ "\nLAYISOX to Isolate Xref Layers LAYUNISOX to unisolate it ")
  2. (defun c:LAYISOX (/ *error* i eName layerName layers acDoc)
  3.   (princ "\rLAYISOX to Isolate Xref Layers \rLAYUNISOX to unisolate it ")
  4.  
  5.   (defun *error* (msg)
  6.     (if acDoc
  7.       (vla-endundomark acDoc)
  8.     )
  9.     (cond ((not msg))                                                   ; Normal exit
  10.           ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
  11.           ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
  12.     )
  13.     (princ)
  14.   )
  15. (layerstate-save "igal" nil nil)
  16. (command "filedia" "1")
  17.   (setq i 0)
  18.   (while
  19.     (setq eName
  20.            (car
  21.              (nentsel
  22.                (strcat
  23.                  "\nSelect objects on the XREF layer(s) to be isolated: "
  24.                  (if (< 0 i)
  25.                    (strcat (itoa i) " found ")
  26.                    ""
  27.                  )
  28.                )
  29.              )
  30.            )
  31.     )
  32.      (setq i (1+ i))
  33.      (if (and (not (vl-position
  34.                      (setq layerName (cdr (assoc 8 (entget eName))))
  35.                      layers
  36.                    )
  37.               )
  38.               (not (vl-position (strcase layerName) '("0" "DEFPOINTS")))
  39.          )
  40.        (setq layers (cons layerName layers))
  41.      )
  42.   )
  43.  
  44.   (if layers
  45.     (progn
  46.  
  47.       ;; start an undomark
  48.       )
  49.       (vlax-for oLayer (vla-get-layers acDoc)
  50.  
  51.         ;; if an xref layer
  52.         (if (and (vl-string-search
  53.                    "|"
  54.                    (setq layerName (vla-get-name oLayer))
  55.                  )
  56.                  (not (vl-position layerName layers))
  57.             )
  58.           (vla-put-layeron oLayer :vlax-false)
  59.         )
  60.       )
  61.     )
  62.   )
  63.   (*error* nil)
  64. )
  65. (defun c:LAYUNISOX()
  66.  
  67. (layerstate-restore "igal" nil nil)
  68. (command "filedia" "1")
  69.  
  70. )