Jump to content

Can't Find Layer Hidden In Unknown Block


"Mitch"

Recommended Posts

I received a drawing that contains a layer in the manager box. But when I attempted to Quick Select that layer, the result returns as "0" and this same layer cannot be deleted, since the message tells me that layers with objects cannot be deleted. I thawed all layers and still get "0" and the layer won't delete. This should mean that the layer is hidden inside a block. This drawing has several hundreds of blocks! Is there an application within AutoCAD that will reveal to me which block that layer is in?

Link to comment
Share on other sites

So you purged all the blocks 1st ? That reduces the  total number of blocks left need to do a couple of times.

 

If its a CIV3D dwg it can have styles in it with layers and purge will not remove unused. PURGESTYLES but thats a CIV3D command.

 

Did you google "get entities in block autocad lisp" lots of answers.

Link to comment
Share on other sites

My first strategy would be to freeze all other layers. With any luck, you'll see the bogus item immediately. When you select it, you'll see the block it belongs to.

 

My next strategy would be to change the color of that layer to some bright color that will stand out. If there's an object in a block on that layer, and its color isn't overridden, you should be able to spot it quickly.

 

Beyond that, I'd have to think that it's an End Definition object. When you create a block, there's a phantom object on the current layer that gets tacked onto the block definition. You can't see it, you can't select it, you'd never know it was there except in this case. LAYDEL should get rid of it.

 

 

Link to comment
Share on other sites

  • 3 weeks later...

I have a LISP Routine that I found on here that sets all objects within blocks in the drawing to layer 0 then i purge out those layers.

 

(defun c:norm (/ *error* adoc lst_layer func_restore-layers)

 (defun *error* (msg)
   (func_restore-layers)
   (vla-endundomark adoc)
   (princ msg)
   (princ)
   ) ;_ end of defun

 (defun func_restore-layers ()
   (foreach item lst_layer
     (vla-put-lock (car item) (cdr (assoc "lock" (cdr item))))
     (vl-catch-all-apply
       '(lambda ()
          (vla-put-freeze
            (car item)
            (cdr (assoc "freeze" (cdr item)))
            ) ;_ end of vla-put-freeze
          ) ;_ end of lambda
       ) ;_ end of vl-catch-all-apply
     ) ;_ end of foreach
   ) ;_ end of defun

 (vl-load-com)
 (vla-startundomark
   (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
   ) ;_ end of vla-startundomark
 (if (and (not (vl-catch-all-error-p
                 (setq selset
                        (vl-catch-all-apply
                          (function
                            (lambda ()
                              (ssget '((0 . "INSERT")))
                              ) ;_ end of lambda
                            ) ;_ end of function
                          ) ;_ end of vl-catch-all-apply
                       ) ;_ end of setq
                 ) ;_ end of vl-catch-all-error-p
               ) ;_ end of not
          selset
          ) ;_ end of and
   (progn
     (vlax-for item (vla-get-layers adoc)
       (setq
         lst_layer (cons (list item
                               (cons "lock" (vla-get-lock item))
                               (cons "freeze" (vla-get-freeze item))
                               ) ;_ end of list
                         lst_layer
                         ) ;_ end of cons
         ) ;_ end of setq
       (vla-put-lock item :vlax-false)
       (vl-catch-all-apply
         '(lambda () (vla-put-freeze item :vlax-false))
         ) ;_ end of vl-catch-all-apply
       ) ;_ end of vlax-for
     (foreach blk_def
              (mapcar
                (function
                  (lambda (x)
                    (vla-item (vla-get-blocks adoc) x)
                    ) ;_ end of lambda
                  ) ;_ end of function
                ((lambda (/ res)
                   (foreach item (mapcar
                                   (function
                                     (lambda (x)
                                       (vla-get-name
                                         (vlax-ename->vla-object x)
                                         ) ;_ end of vla-get-name
                                       ) ;_ end of lambda
                                     ) ;_ end of function
                                   ((lambda (/ tab item)
                                      (repeat (setq tab  nil
                                                    item (sslength selset)
                                                    ) ;_ end setq
                                        (setq
                                          tab
                                           (cons
                                             (ssname selset
                                                     (setq item (1- item))
                                                     ) ;_ end of ssname
                                             tab
                                             ) ;_ end of cons
                                          ) ;_ end of setq
                                        ) ;_ end of repeat
                                      tab
                                      ) ;_ end of lambda
                                    )
                                   ) ;_ end of mapcar
                     (if (not (member item res))
                       (setq res (cons item res))
                       ) ;_ end of if
                     ) ;_ end of foreach
                   (reverse res)
                   ) ;_ end of lambda
                 )
                ) ;_ end of mapcar
       (vlax-for ent blk_def
         (vla-put-layer ent "0")
         (vla-put-color ent 0)
         (vla-put-lineweight ent aclnwtbyblock)
         (vla-put-linetype ent "byblock")
         ) ;_ end of vlax-for
       ) ;_ end of foreach
     (func_restore-layers)
     (vla-regen adoc acallviewports)
     ) ;_ end of progn
   ) ;_ end of if
 (vla-endundomark adoc)
 (princ)
 ) ;_ end of defun

 

If that doesn't work you can run purge then at the top click onto "find Non-Purgeable Items" and in the details of the selected layer it should tell you if anything is still hiding on the layer you dont want and usually where to find it.

 

image.png.bcfcce834764736e9f1d20a5f2a4fc6c.png

 

hopefully this helps.

  • Like 1
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...