@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