Simple list of layer contents

Simple list of layer contents

Netelaana
Enthusiast Enthusiast
1,380 Views
7 Replies
Message 1 of 8

Simple list of layer contents

Netelaana
Enthusiast
Enthusiast

Can't seem to find any other threads on the topic - if I missed it, please point me in the right direction.

 

I have an ambiguously named layer with contents spread (presumably) throughout a drawing in various blocks (hundreds), modelspace, and paperspace (dozens of layouts). I would like to find out what is actually on that layer.

 

Is there a way to get a simple list of the contents of any given layer? something like a pared down dblist but just for a single layer? most helpful would be a list that looks like:

 

ObjectID1 - ObjectType1 - ObjectLocation1(model or layout XXX or block XXX)-ObjectXCoord1-ObjectYCoord1

ObjectID2 - ObjectType1 - ObjectLocation2(model or layout XXX or block XXX)-ObjectXCoord2-ObjectYCoord2

etc...

 

even more helpful would be a way to zoom to each object...

 

does anything along this vein exist?

 

thanks in advance!

0 Likes
Accepted solutions (1)
1,381 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

If you have acad 2020+ then you can try the upgraded PURGE command. Newly there is the "Non-Purgeable" tab... with list of objects... even a zoom button is there. Seems like made just  for you.

 

Z9E3zK5E_0-1591219481153.png

 

0 Likes
Message 3 of 8

Netelaana
Enthusiast
Enthusiast

Sorry , forgot to include that pertinent info - I am running AutoCAD 2018 - no bells or whistles. That does look pretty much like what I am looking for though.

 

Any workarounds,lisp, or other options for 2018?

0 Likes
Message 4 of 8

imadHabash
Mentor
Mentor

Hi,

for selecting same layer objects you can try LAYISO , QSELECT , SELECTSIMILAR and LAYWALK commands . 

 

 

 

Imad Habash

EESignature

0 Likes
Message 5 of 8

Netelaana
Enthusiast
Enthusiast

Yes, I am aware of those tools, however they are severely limiting in my case since they do not look inside blocks or layouts (unless you are in one, and then it does not vet the rest of the drawing). As mentioned, there are hundreds of blocks and dozens of layouts that would need to individually be opened and vetted.

 

dblist gives me the information, but only piecemeal and gives it for every object in the entire drawing (ie a verbose dblist filtered for a single layer would do the trick)

 

dataextraction sort of works, but is quite the process, and then I need to fiddle with the spreadsheet to get my list. it seems that it would be rather straightforward to have a lisp that runs through the objects in the drawing and spits out the information limited to just the layer of interest - it is way beyond the limits of my coding skills though.

0 Likes
Message 6 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Not really sure if this helps, but it was easy enought.. so here you go.

 

 

(vl-load-com)

(defun c:LayerObjects ( / l c i s e d)
  
  (setq l (getstring "\nLayer name <current>: "))
  (setq c 1000
	i -1)
  
  (if (= l "") (setq l (getvar 'clayer)))
  (or (tblsearch "LAYER" l)
      (prompt "\nError: There is no '" l "' layer in the drawing.")
      (exit))
  
  (if (setq s (ssget "_X" (list (cons 8 l))))
    (repeat (sslength s)
      (setq e (ssname s (setq i (1+ i))))
      (setq d (entget e))
      (princ (strcat "\n"
		     (itoa (setq c (1+ c))) ": " (cdr (assoc 5 d))
		     " - " (strcase (cdr (assoc 0 d)))
		     (if (= (cdr (assoc 0 d)) "INSERT")
		       (strcat ":" (if (vlax-property-available-p (setq o (vlax-ename->vla-object e)) 'EffectiveName)
				     (vla-get-EffectiveName o)
				     (vla-get-Name o)))
		       "")
		     " - Layout: " (cdr (assoc 410 d))
		     " - " (cond ((vl-princ-to-string (cdr (assoc 10 d)))) (""))))))
  
  (vlax-for b (vla-get-Blocks (vla-get-activeDocument (vlax-get-acad-object)))
    (and (= 0 (vlax-get b 'islayout))
	 (= 0 (vlax-get b 'isxref))
	 (/= "AcDbBlockReference" (vlax-get b 'ObjectName))
	 (vlax-for o b
	   (if (= l (vlax-get o 'Layer))
	     (princ (strcat "\n"
			    (itoa (setq c (1+ c))) ": " (vlax-get o 'Handle)
			    " - " (strcase (substr (vlax-get o 'ObjectName) 5))
			    (if (= (vlax-get o 'ObjectName) "AcDbBlockReference")
			      (strcat ": " (if (vlax-property-available-p o 'EffectiveName)
					     (vla-get-EffectiveName o)
					     (vla-get-Name o)))
			      "")
			    " - " (strcat "InBlock: " (vla-get-Name b))))))))
  (princ)
  )
0 Likes
Message 7 of 8

RobDraw
Mentor
Mentor

Isolate the layer, select everything visible, and LIST?


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes
Message 8 of 8

Netelaana
Enthusiast
Enthusiast

@ВeekeeCZ wrote:

Not really sure if this helps, but it was easy enough.. so here you go.

 

 

(vl-load-com)

(defun c:LayerObjects ( / l c i s e d)
  
  (setq l (getstring "\nLayer name <current>: "))
  (setq c 1000
	i -1)
  
  (if (= l "") (setq l (getvar 'clayer)))
  (or (tblsearch "LAYER" l)
      (prompt "\nError: There is no '" l "' layer in the drawing.")
      (exit))
  
  (if (setq s (ssget "_X" (list (cons 8 l))))
    (repeat (sslength s)
      (setq e (ssname s (setq i (1+ i))))
      (setq d (entget e))
      (princ (strcat "\n"
		     (itoa (setq c (1+ c))) ": " (cdr (assoc 5 d))
		     " - " (strcase (cdr (assoc 0 d)))
		     (if (= (cdr (assoc 0 d)) "INSERT")
		       (strcat ":" (if (vlax-property-available-p (setq o (vlax-ename->vla-object e)) 'EffectiveName)
				     (vla-get-EffectiveName o)
				     (vla-get-Name o)))
		       "")
		     " - Layout: " (cdr (assoc 410 d))
		     " - " (cond ((vl-princ-to-string (cdr (assoc 10 d)))) (""))))))
  
  (vlax-for b (vla-get-Blocks (vla-get-activeDocument (vlax-get-acad-object)))
    (and (= 0 (vlax-get b 'islayout))
	 (= 0 (vlax-get b 'isxref))
	 (/= "AcDbBlockReference" (vlax-get b 'ObjectName))
	 (vlax-for o b
	   (if (= l (vlax-get o 'Layer))
	     (princ (strcat "\n"
			    (itoa (setq c (1+ c))) ": " (vlax-get o 'Handle)
			    " - " (strcase (substr (vlax-get o 'ObjectName) 5))
			    (if (= (vlax-get o 'ObjectName) "AcDbBlockReference")
			      (strcat ": " (if (vlax-property-available-p o 'EffectiveName)
					     (vla-get-EffectiveName o)
					     (vla-get-Name o)))
			      "")
			    " - " (strcat "InBlock: " (vla-get-Name b))))))))
  (princ)
  )

Simple maybe (its more than I could have cobbled together)- but nailed it. Thanks!!!

 

I might never have found the couple random mleaders someone stuck on this layer buried in a block - with this it took about two seconds....

0 Likes