XLIST not showing full xref layer name

XLIST not showing full xref layer name

kameron1967
Collaborator Collaborator
5,734 Views
16 Replies
Message 1 of 17

XLIST not showing full xref layer name

kameron1967
Collaborator
Collaborator

Hi guys,

 

I am not sure if Autocad cared, but it seems that the xlist command is not useful at all when trying to list or see what layer an xref'ed entity is residing on.  Do we have a routine to allow you to show the full xref path - like a modified xlist command?

 

Thanks in advance! 🙂

Accepted solutions (1)
5,735 Views
16 Replies
Replies (16)
Message 2 of 17

kameron1967
Collaborator
Collaborator
I know this is probably one of the hardest routine to create. I am interested if anyone's tried to tackle this before. Autodesk knows their xlist command shows only certain number of characters. Well, with xref names being so long, sometimes you don't get to see the layer name at all because xlist only shows 20 characters. If we can have a routine that displays 50 characters, that would help everyone greatly. I know everyone has the same issue that I do. Thanks for reading my thread guys. And thank you always for your support - you know who you are! 🙂
0 Likes
Message 3 of 17

Anonymous
Not applicable

Have you tried renamimg your xrefs so the name is not too long? I often find it quite useful to rename xrefs to either a shortened name or a standard name for all projects.

0 Likes
Message 4 of 17

kameron1967
Collaborator
Collaborator
Well, nowadays, it's not feasible to try to rename every xrefs. KentCooper has one suggestion, and that's to double-click on the xref (acting like we're going to edit it in place), check the layer info on the entity and close out without saving. That might be what I will need to do in order to get the layer info. A bit of a pain, but it'll be my last resort until something better comes up. 🙂
0 Likes
Message 5 of 17

hmsilva
Mentor
Mentor
Accepted solution

Hi kameron1967,

perhaps something like this

 

(vl-load-com)
(defun c:demo (/ col ent obj pos sel)
  (while (setq sel (nentsel "\nSelect nested xref or block object to list: "))
    (setq ent (entget (car sel)))
    (setq obj (vlax-ename->vla-object (car sel)))
    (setq col (vlax-get obj 'color))
    (cond ((= col 256)
           (setq col "ByBlock")
          )
          ((= col 255)
           (setq col "ByLayer")
          )
          ((setq pos (vl-position col '(1 2 3 4 5 6 7)))
           (setq col (nth pos '("Red" "Yellow" "Green" "Cyan" "Blue" "Magenta" "White")))
          )
          (T
           (setq col (itoa col))
          )
    )
    (alert (strcat "Object:        "
                   (cdr (assoc 0 ent))
                   "\nLayer:       "
                   (cdr (assoc 8 ent))
                   "\nColor:       "
                   col
                   "\nLinetype:    "
                   (vlax-get obj 'Linetype)
           )
    )
  )
  (princ)
)

 

Hope this helps,
Henrique

EESignature

Message 6 of 17

Kent1Cooper
Consultant
Consultant

@hmsilva wrote:

....

 

....
(while (setq sel (nentsel "\nSelect nested xref or block ....

....


That has a significant difference in result from XLIST if you have any nested objects in the Xref.  XLIST seems [admittedly in very limited testing] to return information about the topmost-level nested object within the Xref, whereas (nentsel) will see the deepest-level nested object.  For instance, say I have some Lines & Polylines defined as a refrigerator Block that's Inserted into an apartment-unit plan, which is also defined as a Block, and that is Inserted in an overall building Floor Plan, and that Plan drawing is Xref'd into another drawing as a base for Electrical layouts.  If, in that Electrical drawing file, I pick on the refrigerator using (nentsel), what it finds is the Line or Polyline I pick on that's part of the refrigerator Block.  If I pick on the same thing in XLIST, it sees not the deepest-level nested Line/Polyline, nor the intermediate-level nested refrigerator Block, but the apartment-unit plan Block that's the highest-level nested object in the Xref'd overall Floor Plan drawing.  Since I wouldn't assume I would always want information at only that one level of nesting, I really like REFEDIT because of it allows me to designate at which level I want to look at things.

Kent Cooper, AIA
0 Likes
Message 7 of 17

hmsilva
Mentor
Mentor

@Kent1Cooper wrote:

@hmsilva wrote:

....

 

....
(while (setq sel (nentsel "\nSelect nested xref or block ....

....


That has a significant difference in result from XLIST if you have any nested objects in the Xref.  XLIST seems [admittedly in very limited testing] to return information about the topmost-level nested object within the Xref, whereas (nentsel) will see the deepest-level nested object.  For instance, say I have some Lines & Polylines defined as a refrigerator Block that's Inserted into an apartment-unit plan, which is also defined as a Block, and that is Inserted in an overall building Floor Plan, and that Plan drawing is Xref'd into another drawing as a base for Electrical layouts.  If, in that Electrical drawing file, I pick on the refrigerator using (nentsel), what it finds is the Line or Polyline I pick on that's part of the refrigerator Block.  If I pick on the same thing in XLIST, it sees not the deepest-level nested Line/Polyline, nor the intermediate-level nested refrigerator Block, but the apartment-unit plan Block that's the highest-level nested object in the Xref'd overall Floor Plan drawing.  Since I wouldn't assume I would always want information at only that one level of nesting, I really like REFEDIT because of it allows me to designate at which level I want to look at things.


Fully agree!

The XLIST command returns the information about the topmost-level nested object within the Xref, and with REFEDIT command we can choose which level we want look at things.

 

But, my goal was just trying to mimic the XLIST command, as OP request, and return the full layer name, unsuccessfully...

 

Let's see if this quickly revised code, works as OP request...

 

(vl-load-com)
(defun c:demo (/ col ent obj name pos sel)
  (while (setq sel (nentsel "\nSelect nested xref or block object to list: "))
    (if (> (setq len (length sel)) 2)
      (progn
        (setq sel (last sel))
        (if (> (setq len (length sel)) 1)
          (setq sel (nth (- len 2) sel))
          (setq sel (car sel))
        )
      )
      (setq sel (car sel))
    )
    (setq ent (entget sel))
    (setq obj (vlax-ename->vla-object sel))
    (setq col (vlax-get obj 'color))
    (cond ((= col 256)
           (setq col "ByBlock")
          )
          ((= col 255)
           (setq col "ByLayer")
          )
          ((setq pos (vl-position col '(1 2 3 4 5 6 7)))
           (setq col (nth pos '("Red" "Yellow" "Green" "Cyan" "Blue" "Magenta" "White")))
          )
          (T
           (setq col (itoa col))
          )
    )
    (alert (strcat "Object:        "
                   (if (= (setq name (cdr (assoc 0 ent))) "INSERT")
                     (strcat "BLOCK"
                             "\nName:       "
                             (vla-get-effectivename obj)
                     )
                     name
                   )
                   "\nLayer:       "
                   (cdr (assoc 8 ent))
                   "\nColor:       "
                   col
                   "\nLinetype:    "
                   (vlax-get obj 'Linetype)
           )
    )
  )
  (princ)
)

 

Henrique

EESignature

Message 8 of 17

kameron1967
Collaborator
Collaborator
Henrique - this is exactly what I was looking for! I think a lot of people would be so thrilled to have the ability to list the referenced line work at long last! Thanks again!! 🙂
0 Likes
Message 9 of 17

hmsilva
Mentor
Mentor

@kameron1967 wrote:
Henrique - this is exactly what I was looking for! I think a lot of people would be so thrilled to have the ability to list the referenced line work at long last! Thanks again!! 🙂

You're welcome, kameron1967
Glad I could help

Henrique

EESignature

0 Likes
Message 10 of 17

awkeller88
Advocate
Advocate

In my research on the topic I also came across another solution and thought I would share. If you have the permission to modify the existing code this may be the solution for you. Also, you could just make the changes and overwrite the existing xlist command.

 

http://cadtips.cadalyst.com/misc-user-tools/show-entire-layer-name-xlist-dialog-box

 

~Andy

 

PS. Kudos on the code. The second round of code created here fixed the grabbing the lowest level (I get the layer my nested block is on instead of 0) however it was buggy when it came to top layer stuff (line work in the xref), when I selected those I just got the layer the xref was on.

 

PSS. Or you can run -XLIST on the command line and you don't have to worry about character spill over.

Message 11 of 17

john.uhden
Mentor
Mentor

That's funny.  I just wrote one the other day almost just like that, complete with using (alert) because it can handle multiple lines of text and long strings.

Good job!

John F. Uhden

Message 12 of 17

awkeller88
Advocate
Advocate

Do you mind if I could have a look at what you have done. The link I sent gets you most the way but there is a few little bugs in the program they supply.

 

~Andy

0 Likes
Message 13 of 17

john.uhden
Mentor
Mentor
I'm working on refining the parents' info.
Also including locked and NoPlot.

John F. Uhden

0 Likes
Message 14 of 17

john.uhden
Mentor
Mentor

It seems to work okay.

 Once loaded, you can use the command LAI (for LayerInfo)

 

John F. Uhden

Message 15 of 17

mbenderHUDPX
Explorer
Explorer

A late reponse, but I've always fixed the xlist command with some assitance from the AutoCad God Queen herself, LA

https://lynn.blogs.com/lynn_allens_blog/2009/07/an-autocad-hip-tip-for-xlist-with-long-layer-names.h...

Message 16 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

If I recall correctly, nentsel will return the enames of the entire family tree, in order.

I have somewhere an AutoLisp widget that displays all the ancestors in a list_box so that you can pick any included layer and change its properties.

John F. Uhden

0 Likes
Message 17 of 17

john.uhden
Mentor
Mentor

@awkeller88 ,

Here ya go.  You could add any other properties I missed, like say transparency (I have only 2002 at home).

(defun C:LAYINFO ( / *error* Doc etype cmdecho e obj layobj)
   ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
   ;*         LAYINFO.LSP   by  John F. Uhden                             *
   ;*                           2 Village Road                            *
   ;*                           Sea Girt, NJ  08750                       *
   ;* * * * * * * * * * Please do not delete this heading!  * * * * * * * * 

   ;; Program reports the properties of a layer associated with a selected entity.
   (gc)
   (prompt "\nLAYINFO v1.0 (c)2019, John F. Uhden")

   (defun *error* (err)
      (setvar "cmdecho" cmdecho)
      (vla-endundomark Doc)
      (cond
         ((not err))
         ((wcmatch (strcase err) "*CANCEL*,*QUIT*")
            (vl-exit-with-error "\r                                              ")
         )
         (1 (vl-exit-with-error (strcat "\r*ERROR*: " err)))
      )
      (princ)
   )
   ;;-------------------------------------------
   ;; Initialize drawing and program variables:
   ;;
   (setq Doc (vlax-get (vlax-get-acad-object) 'Activedocument)
              cmdecho (getvar "cmdecho")
   )
   (vla-endundomark Doc)
   (vla-startundomark Doc)
   (setvar "cmdecho" 0)
   (command "_.expert" (getvar "expert")) ;; dummy command

  ;; Function to convert a string with delimiters into a list.
  ;; pat is the delimiter and can contain multiple characters
   (defun @str2list (str pat / i j n lst)
     (cond
       ((/= (type str)(type pat) 'STR))
       ((= str pat)'(""))
       (T
         (setq i 0 n (strlen pat))
         (while (setq j (vl-string-search pat str i))
           (setq lst (cons (substr str (1+ i)(- j i)) lst)
                 i (+ j n)
           )
         )
         (reverse (cons (substr str (1+ i)) lst))
       )
     )
   )
   ;; Using the famous (at least with me),
   ;; Stephan Koster method of a loooong and.
   (and
      (setq e (car (nentsel "\nSelect entity on layer to question: ")))
      (setq etype (cdr (assoc 0 (entget e))))
      (setq name (cdr (assoc 8 (entget e))))
      (setq layer (tblobjname "Layer" name))
      (setq ent (entget layer))
      (setq color (cdr (assoc 62 ent)))
      (setq layobj (vlax-ename->vla-object layer))
      (setq frozen (vlax-get layobj 'Freeze))
      (setq On (vlax-get layobj 'LayerOn))
      (setq Ltype (vlax-get layobj 'Linetype))
      (setq Plottable (vlax-get layobj 'Plottable))
      (setq LWeight (vlax-get layobj 'Lineweight))
      (princ (strcat "\nObject:\t" Etype))
      (foreach sym '(Name color ltype frozen On Plottable Lweight)
        (princ (strcat "\n" (vl-princ-to-string sym) ":\t"))
        (princ (eval sym))
      )
      (textscr)
     ;; (vlax-dump-object layobj)
   )
   (*error* nil)
)
(defun c:LINF ()(c:LAYINFO))

John F. Uhden

0 Likes