Jump to content

Recommended Posts

Posted

I stumbled upon this routine by Ronjonp. It isolates an xref layer and unisolates it. I was wondering if i selected an xref layer entity and a dimension within modelspace, could it isolate both layers?

 

;;; AUTHOR
;;; Copyright© 2009 Ron Perez (ronperez AT gmail dot com)
;;; Isolates selected object layers (similar to LAYISO express tool but will work with nested xref layers)
;;; ISO to invoke...UNISO to restore layer settings (saved in global variable *rjp-savedlayersettings*)

(defun c:iso (/			rjp-dxf		  rjp-freezeallbutselected
	      rjp-getnested	rjp-getlayers	  e
	      out		rjp-nentsel	  rjp-undobegin
	      rjp-undoend
	     )
  (vl-load-com)
  (if *rjp-savedlayersettings*
    (c:uniso)
  )
  (defun rjp-dxf (code ent) (cdr (assoc code (entget ent))))
  (defun rjp-getlayers (ent) (tblobjname "layer" (rjp-dxf 8 ent)))
  (defun rjp-freezeallbutselected (lst / lay out)
    (while (setq lay (tblnext "layer" (not lay)))
      (setq out (cons (tblobjname "layer" (cdr (assoc 2 lay))) out))
    )
    (mapcar '(lambda (x) (vl-catch-all-apply 'setvar (list "clayer" (rjp-dxf 2 x))))
	    lst
    )
    (mapcar '(lambda (x) (vl-catch-all-apply 'vla-put-freeze (list x :vlax-true)))
	    (setq
	      out (mapcar
		    'vlax-ename->vla-object
		    (vl-remove-if
		      '(lambda (x)
			 (or (vl-position x lst)
			     (= (vla-get-freeze (vlax-ename->vla-object x)) :vlax-true)
			 )
		       )
		      out
		    )
		  )
	    )
    )
    out
  )
  (defun rjp-nentsel (msg / p out)
    (setvar "ErrNo" 0)
    (while
      (not
	(cond
	  ((and (null (setq p (nentsel (strcat "\n" msg)))) (/= 52 (getvar 'errno)))
	   (prompt "\nSelection missed please try again...")
	  )
	  ((null p) t)
	  ((progn (setq out p)))
	)
      )
    )
    out
  )
  (defun rjp-undobegin (/ doc)
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (vla-endundomark doc)
    (vla-startundomark doc)
    (princ)
  )
  (defun rjp-undoend (/ doc)
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (vla-endundomark doc)
    (princ)
  )
  (defun rjp-getnested (ent)
    (if	ent
      (if (cadddr ent)
	(append (list (car ent)) (cadddr ent))
	(list (car ent))
      )
    )
  )
  (while (setq e (rjp-nentsel "Select object(s) to isolate layers: "))
    (setq out (cons (rjp-getnested e) out))
    (princ (apply 'strcat
		  (mapcar '(lambda (x) (strcat (rjp-dxf 8 x) "  ")) (rjp-getnested e))
	   )
    )
  )
  (if (setq out (apply 'append out))
    (progn
      (rjp-undobegin)
      (setq *rjp-savedlayersettings*
	     (rjp-freezeallbutselected
	       (mapcar 'rjp-getlayers out)
	     )
      )
      (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
      (rjp-undoend)
      (defun c:uniso (/)
	(if *rjp-savedlayersettings*
	  (progn
	    (mapcar
	      '(lambda (x) (vl-catch-all-apply 'vla-put-freeze (list x :vlax-false)))
	      *rjp-savedlayersettings*
	    )
	    (vla-regen (vla-get-activedocument (vlax-get-acad-object))
		       acactiveviewport
	    )
	    (setq *rjp-savedlayersettings* nil)
	  )
	  (princ "\nNo layer settings saved...")
	)
	(princ)
      )
    )
    (princ "\nNothing selected...")
  )
  (princ)
)

 

Posted (edited)

That's a blast from the past 😳  ... I found this in my slew of routines, give it a try.

 

;;; AUTHOR
;;; Copyright© 2007 Ron Perez
;;;

(defun c:nlayiso (/ llst x n)
  (and *frzlyrs* (c:nlayuniso))
  (while (setq x (nentsel "\nSelect objects on the layer(s) to be isolated: "))
    (foreach z (append (list (car x)) (cadddr x))
      (setq n (cdr (assoc 8 (entget z))))
      (or (member n llst) (progn (setq llst (cons n llst)) (princ (strcat "\n" n))))
    )
  )
  (if llst
    (progn
      (vlax-for	x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
	(or (member (vla-get-name x) llst)
	    (progn (setq *frzlyrs* (cons (cons x (vla-get-freeze x)) *frzlyrs*))
		   (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-freeze (list x :vlax-true)))
	    )
	)
      )
      (defun c:nlayuniso (/)
	(if *frzlyrs*
	  (foreach x *frzlyrs*
	    (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-freeze (list (car x) (cdr x))))
	  )
	)
	(command "._regen")
	(setq *frzlyrs* nil)
	(princ)
      )
    )
  )
  (princ)
)

 

Edited by ronjonp
Posted (edited)

Ron! So AWESOME! Sorry to bring up the past;) Thank you for sharing that! Works great.

 

no more racking my head through all the layers!

Edited by rcb007
Posted
7 minutes ago, rcb007 said:

Ron! So AWESOME! Sorry to bring up the past;) Thank you for sharing that! Works great.

 

no more racking my head through all the layers!

Glad to help 🍻

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...