Jump to content

Show xref layer


Efeezy

Recommended Posts

Does anyone have a lisp for showing the xref layer. I am want to click on a bock or line and see what layer it is on so I can go into layer manager and change the color to bold.

Link to comment
Share on other sites

I use this for showing the xref layer but it doesn't always work right.

 

(defun C:XRL ()
 (setq EnL (entget (car (nentsel "\nSelect object to identify layer it is on : ")))
       LNm (cdr (assoc 8 EnL))
 )
 (princ "\n Entity layer name: ")
 (princ LNm)
(prin1))


(defun C:XRF ()
 (setq EnL (entget (car (nentsel "\nSelect Layer to Freeze : ")))
       LNm (cdr (assoc 8 EnL))
 )
 (command "layer" "f" LNm "")
 (princ "\n Layer: ")(princ LNm)(princ " is now frozen.")
(princ))

Link to comment
Share on other sites

I use the following that I modified to suit. I only added the ability for it to tell me which layer using LFPNN.

 

Thanks.

 

;;  LayerQuellPick.lsp [command names: LOP, LOPN, LFP, LFPN]
;;  To "Quell" [turn Off or Freeze] Layers of Picked objects or Picked Nested objects.
;;  If selected object is on current Layer, changes current Layer to first one in Layer table
;;    that is neither off/frozen nor Xref-dependent nor that of selected object, and notifies
;;    User of new current Layer.  [starting current Layer remains shown in Layer Properties
;;    Toolbar pull-down until command is terminated, but if Properties box is up, changes
;;    of current Layer are reflected immediately in its General section, Layer slot.]
;;  If selected nested object is part of a Block/Xref, and on Layer 0 within that reference's
;;    definition, turns off or freezes not Layer 0, but the deepest-nested non-0 Layer on which
;;    that reference or a containing reference is inserted, i.e. where nested object "appears."
;;  [Quirk I haven't found a way around yet: if Layer 0 is off or frozen, things on Defpoints
;;    Layer, even if visible, can't be selected; that Layer can't be quelled while Layer 0 is
;;    (using these commands, though it can be via Layer Manager or Toolbar).]
;;  Kent Cooper, November 2011

;; Modified by Chau Huh, April 2015

(defun C:LOP (); = Layer Off by Picking object(s) [top-level]
   (LQC entsel "" "turn Off" "_off")
); defun - C:LOP

(defun C:LOPN (); = Layer Off by Picking object(s) or Nested object(s)
   (LQC nentsel "/nested object" "turn Off" "_off")
); defun - C:LOPN

(defun C:LFP (); = Layer Freeze by Picking object(s) [top-level]
   (LQC entsel "" "Freeze" "_freeze")
); defun - C:LFP

(defun C:LFPN (); = Layer Freeze by picking object(s) or Nested object(s)
   (LQC nentsel "/nested object" "Freeze" "_freeze")
); defun - C:LFPN

(defun C:LFPNN (); = Layer Freeze by picking object(s) or Nested object(s)
   (LQCC nentsel "/nested object" "Identify" "_freeze")
); defun - C:LFPNN

(defun LQC (func pr1 pr2 opt / *error* cmde ent edata layq nestlist nlayq ldata layc)
 ; = Layer Quell with Current layer changed if necessary
 (defun *error* (errmsg); don't display error message if cancelled with Esc
   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
     (princ (strcat "\nError: " errmsg))
   ); end if
   (setvar 'cmdecho cmde)
 ); defun - *error*
 (setq cmde (getvar 'cmdecho))
 (setvar 'cmdecho 0)
 (while
   (and
     (not ; to return T when (while) loop below is satisfied
       (while
         (and
           (not (setq ent (func (strcat "\nSelect object" pr1 " on Layer to " pr2 ": "))))
           (= (getvar 'errno) 7)
         ); and
         (prompt "\nNothing selected -- try again.")
       ); end while
     ); not
     ent ; something selected
   ); and
   (setq
     edata (entget (car ent))
     layq ; = LAYer to Quell [turn Off or Freeze]
       (if (= (cdr (assoc 8 edata)) "0"); on Layer 0
         (cond ; then
           ((> (length ent) 2); nested entity [other than Attribute] in Block/Xref
             (setq nestlist (last (nentselp (cadr ent)))); stack of references nested in
             (while
               (and
                 nestlist ; still nesting level(s) remaining
                 (= (setq nlayq (cdr (assoc 8 (entget (car nestlist))))) "0"); = Nested [non-0] LAYer to Quell
               ); and
               (setq nestlist (cdr nestlist)); move up a level if present
             ); while
             nlayq
               ; lowest-level non-0 Layer of nested or containing reference(s); 0 if that all the way up
           ); non-Attribute nested entity on Layer 0 condition
           ((= (cdr (assoc 0 edata)) "ATTRIB"); Attribute in Block
             (cdr (assoc 8 (entget (cdr (assoc 330 edata))))); Block's Layer
           ); Attribute on Layer 0 condition
           ("0"); none-of-the-above condition
         ); cond - then
         (cdr (assoc 8 edata)); else - Layer of entity/nested entity
       ); if & layq
   ); setq
   (if (= layq (getvar 'clayer)); selected object is on current Layer - find another
     (progn ; then
       (while ; look for Layer that's on, thawed, non-Xref-dependent, not selected object's
         (and
           (setq ldata (tblnext "layer" (not ldata))); still Layer(s) left in table
             ; nil if it gets to end of table without finding qualifying Layer
           (or
             (=
               (setq layc (cdr (assoc 2 ldata))); = LAYer to [possibly] make Current
               layq ; selected object's Layer
             ); =
             (minusp (cdr (assoc 62 ldata))); off [could be made current, but...]
             (= (logand (cdr (assoc 70 ldata)) 1) 1); frozen [can't be made current]
             (wcmatch layc "*|*"); Xref-dependent [can't be made current]
           ); or
         ); and
       ); while
       (if ldata ; found a qualifying Layer
         (setvar 'clayer layc); then - set it current
         (progn ; else - no qualifying Layer
           (alert "No available Layer to make current\nin place of selected object's Layer.")
           (quit)
         ); progn
       ); if
     ); progn
   ); if
   (command "_.layer" opt layq ""); turn off or freeze Layer of selected object
   (princ (strcat "Turning off layer " layq "\n"))
   (if ldata (prompt (strcat "\nCurrent Layer has been changed to " layc ".")))
 ); while
 (setvar 'cmdecho cmde)
 (princ)
); defun - LQC

(defun LQCC (func pr1 pr2 opt / *error* cmde ent edata layq nestlist nlayq ldata layc)
 ; = Layer Quell with Current layer changed if necessary
 (defun *error* (errmsg); don't display error message if cancelled with Esc
   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
     (princ (strcat "\nError: " errmsg))
   ); end if
   (setvar 'cmdecho cmde)
 ); defun - *error*
 (setq cmde (getvar 'cmdecho))
 (setvar 'cmdecho 0)
 (while
   (and
     (not ; to return T when (while) loop below is satisfied
       (while
         (and
           (not (setq ent (func (strcat "\nSelect object" pr1 " on Layer to " pr2 ": "))))
           (= (getvar 'errno) 7)
         ); and
         (prompt "\nNothing selected -- try again.")
       ); end while
     ); not
     ent ; something selected
   ); and
   (setq
     edata (entget (car ent))
     layq ; = LAYer to Quell [turn Off or Freeze]
       (if (= (cdr (assoc 8 edata)) "0"); on Layer 0
         (cond ; then
           ((> (length ent) 2); nested entity [other than Attribute] in Block/Xref
             (setq nestlist (last (nentselp (cadr ent)))); stack of references nested in
             (while
               (and
                 nestlist ; still nesting level(s) remaining
                 (= (setq nlayq (cdr (assoc 8 (entget (car nestlist))))) "0"); = Nested [non-0] LAYer to Quell
               ); and
               (setq nestlist (cdr nestlist)); move up a level if present
             ); while
             nlayq
               ; lowest-level non-0 Layer of nested or containing reference(s); 0 if that all the way up
           ); non-Attribute nested entity on Layer 0 condition
           ((= (cdr (assoc 0 edata)) "ATTRIB"); Attribute in Block
             (cdr (assoc 8 (entget (cdr (assoc 330 edata))))); Block's Layer
           ); Attribute on Layer 0 condition
           ("0"); none-of-the-above condition
         ); cond - then
         (cdr (assoc 8 edata)); else - Layer of entity/nested entity
       ); if & layq
   ); setq
   (if (= layq (getvar 'clayer)); selected object is on current Layer - find another
     (progn ; then
       (while ; look for Layer that's on, thawed, non-Xref-dependent, not selected object's
         (and
           (setq ldata (tblnext "layer" (not ldata))); still Layer(s) left in table
             ; nil if it gets to end of table without finding qualifying Layer
           (or
             (=
               (setq layc (cdr (assoc 2 ldata))); = LAYer to [possibly] make Current
               layq ; selected object's Layer
             ); =
             (minusp (cdr (assoc 62 ldata))); off [could be made current, but...]
             (= (logand (cdr (assoc 70 ldata)) 1) 1); frozen [can't be made current]
             (wcmatch layc "*|*"); Xref-dependent [can't be made current]
           ); or
         ); and
       ); while
       (if ldata ; found a qualifying Layer
         (setvar 'clayer layc); then - set it current
         (progn ; else - no qualifying Layer
           (alert "No available Layer to make current\nin place of selected object's Layer.")
           (quit)
         ); progn
       ); if
     ); progn
   ); if
   (princ (strcat "Layer: " layq "\n"))
   (if ldata (prompt (strcat "\nCurrent Layer has been changed to " layc ".")))
 ); while
 (setvar 'cmdecho cmde)
 (princ)
); defun - LQCC[code]

[/code]

Link to comment
Share on other sites

Thank you, but it doesn't list the layer of the xref. Even if I hit F2 it still doesn't show the xref layer. I am trying to find a nested layer xref list. like Xlist but able to see what layer you clicked on every time. Xlist is inconsistent due to the fact we have long drawing name and it doesn't show the layer sometimes.

Link to comment
Share on other sites

XLIST is the built-in command for that.

 

It may be an Express tool command in 2012, so if it doesn't work make sure the Express Tools are loaded.

Link to comment
Share on other sites

Thank you, but it doesn't list the layer of the xref. Even if I hit F2 it still doesn't show the xref layer. I am trying to find a nested layer xref list. like Xlist but able to see what layer you clicked on every time. Xlist is inconsistent due to the fact we have long drawing name and it doesn't show the layer sometimes.

 

It is working for me...

Link to comment
Share on other sites

You can do that with QUICK PROPERTIES, you just need to set up what attribute information you would like displayed for XRefs. Under Menus, in the CUI, select QUICK PROPERTIES, then you can define what you want displayed.

 

I have never heard of XLIST before, but I tried it on 2013, and seems to work fine.

Menus Quick Properties in the CUI.JPG

Link to comment
Share on other sites

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...