TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on September 13, 2013, 11:08:09 AM

Title: XREFs code
Post by: V-Man on September 13, 2013, 11:08:09 AM
In need of simple code to check the existence of any XREF's in current drawing and if any found LOCK the layer they are inserted on.

Thanks,
Title: Re: XREFs code
Post by: Lee Mac on September 13, 2013, 11:47:26 AM
Try this quick draft:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:lxr ( / a b e i l s x )
  2.     (while (setq a (tblnext "block" (null a)))
  3.         (if (= 4 (logand 4 (cdr (assoc 70 a))))
  4.             (setq b (vl-list* "," (cdr (assoc 2 a)) b))
  5.         )
  6.     )
  7.     (if (and b (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 (apply 'strcat (cdr b)))))))
  8.         (repeat (setq i (sslength s))
  9.             (if (not (member (setq x (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) l))
  10.                 (setq l (cons x l))
  11.             )
  12.         )
  13.     )
  14.     (foreach x l
  15.         (setq e (entget (tblobjname "layer" x))
  16.               a (assoc 70 e)
  17.         )
  18.         (entmod (subst (cons 70 (logior 4 (cdr a))) a e))
  19.     )
  20.     (princ)
  21. )
Title: Re: XREFs code
Post by: Tharwat on September 13, 2013, 12:01:55 PM
Maybe REGEN would be needed after locking layers.
Title: Re: XREFs code
Post by: V-Man on September 13, 2013, 01:20:24 PM
Quote
Lee Mac

Thank you sir for your generous support. That procedure worked perfectly.
Title: Re: XREFs code
Post by: Lee Mac on September 13, 2013, 05:00:27 PM
Thank you sir for your generous support. That procedure worked perfectly.

You're very welcome V-Man  :-)
Title: Re: XREFs code
Post by: tedg on September 16, 2013, 02:17:00 PM
In need of simple code to check the existence of any XREF's in current drawing and if any found LOCK the layer they are inserted on.

Thanks,
Instead of locking whatever layer  they are inserted on, why wouldn't you want to put your xrefs on an appropriate layer and then lock it?
 
Such as G-ANNO-REFR (or what ever your desired standard is)?
 
Just a thought.
 
That way if someone put an xref on the wrong layer such as a text layer, you're not locking that one.
Title: Re: XREFs code
Post by: Kerry on September 16, 2013, 08:02:59 PM

I agree Ted. One option is to name the layer to match the xref name ... 'standards' allowing :-)