AutoCAD Land Desktop (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Find Objects on Layer, so I can Delete the Layer

22 REPLIES 22
Reply
Message 1 of 23
Anonymous
50824 Views, 22 Replies

Find Objects on Layer, so I can Delete the Layer

Using 2004 right now (2007 is kicking my butt)

I just want to delete layer B0.

Express tool Layer Delete won't delete the layer, says it's being referenced by an object.

Layer walk tells me there is 1 object on this layer.

I'm assuming it's being used in a block somewhere, because there are no visible objects on B0 when I isolate it.

How can I find this block? I thought Layer Walk would help me do that, maybe I don't know how the command works or something.

Thanks--
22 REPLIES 22
Message 2 of 23
Anonymous
in reply to: Anonymous

This will search all blocks, including Model Space & Paper Space, and will
return a list of lists containing the (vla-object) and the block in which it
was found.
[code]
(defun findobjonlayer (layer / result)
(vl-load-com)
(if (not (tblsearch "LAYER" layer))
(princ "Layer does not exist.")
(progn
(vlax-for blk
(vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(vlax-for ent blk
(if (eq (strcase (vla-get-layer ent)) (strcase layer))
(setq result (cons (cons ent (vla-get-name blk)) result))
)
)
)
)
)
result
)
[/code]
Usage:
(findobjonlayer "test")
returns:
((# . "*PAPER_SPACE"))


wrote in message news:5517146@discussion.autodesk.com...
Using 2004 right now (2007 is kicking my butt)

I just want to delete layer B0.

Express tool Layer Delete won't delete the layer, says it's being referenced
by an object.

Layer walk tells me there is 1 object on this layer.

I'm assuming it's being used in a block somewhere, because there are no
visible objects on B0 when I isolate it.

How can I find this block? I thought Layer Walk would help me do that,
maybe I don't know how the command works or something.

Thanks--
Message 3 of 23
pkohut-og
in reply to: Anonymous

Type at the command line:
(ssget "x" '((8 . "layername")))

will select all the objects on layername. You can then
use "list p" "erase p" "copy p" ect.

Paul Kohut
Message 4 of 23
Anonymous
in reply to: Anonymous

But this does not find the objects if they reside in Block definitions.

wrote in message news:5517182@discussion.autodesk.com...
Type at the command line:
(ssget "x" '((8 . "layername")))

will select all the objects on layername. You can then
use "list p" "erase p" "copy p" ect.

Paul Kohut
Message 5 of 23
pkohut-og
in reply to: Anonymous

True.

Paul Kohut
Message 6 of 23
Anonymous
in reply to: Anonymous

If you have Express Tools, type laydel.

--
John Mayo
Project Engineer
Conklin Associates
Ramsey, NJ

Civil 3D 2007, LDT 2007, Raster Design 2007
P-IV at 3.5 GHz
2 GB Ram
Nvidea Quadro FX w/ 128 MB Ram
wrote in message news:5517146@discussion.autodesk.com...
Using 2004 right now (2007 is kicking my butt)

I just want to delete layer B0.

Express tool Layer Delete won't delete the layer, says it's being referenced
by an object.

Layer walk tells me there is 1 object on this layer.

I'm assuming it's being used in a block somewhere, because there are no
visible objects on B0 when I isolate it.

How can I find this block? I thought Layer Walk would help me do that,
maybe I don't know how the command works or something.

Thanks--
Message 7 of 23
Anonymous
in reply to: Anonymous

Express tool Layer Delete won't delete the layer, says it's being referenced
by an object.
Message 8 of 23
Anonymous
in reply to: Anonymous

Thats because you probably have it as the current layer. set layer 0 current
then express layer delete


Joe


wrote in message news:5517146@discussion.autodesk.com...
Using 2004 right now (2007 is kicking my butt)

I just want to delete layer B0.

Express tool Layer Delete won't delete the layer, says it's being referenced
by an object.

Layer walk tells me there is 1 object on this layer.

I'm assuming it's being used in a block somewhere, because there are no
visible objects on B0 when I isolate it.

How can I find this block? I thought Layer Walk would help me do that,
maybe I don't know how the command works or something.

Thanks--
Message 9 of 23
Anonymous
in reply to: Anonymous

Thanks for taking the time to provide this information.

Joe: I used the express layer delete command while making sure 0 was current layer again just to be sure, and it said the layer was being referenced in the drawing.

Jeff: I am currently trying to decipher the command you suggested. ? I'll keep trying
Message 10 of 23
Anonymous
in reply to: Anonymous

Sorry akgrrl, for some reason I thought I was in the lisp newsgroup when I
posted that, thereby assuming you'd know what to do with it. I'll doctor it
up a bit and post back in a few minutes.

Jeff

wrote in message news:5517357@discussion.autodesk.com...
Thanks for taking the time to provide this information.

Joe: I used the express layer delete command while making sure 0 was
current layer again just to be sure, and it said the layer was being
referenced in the drawing.

Jeff: I am currently trying to decipher the command you suggested. ? I'll
keep trying
Message 11 of 23
Anonymous
in reply to: Anonymous

Theres some girls up in drafting that are hip to lisp routines. I can print out what you posted and ask them if it makes sense, thanks again.
Message 12 of 23
Anonymous
in reply to: Anonymous

Here's a more polished routine. I had negelcted to include block attributes
in the original version. This one, just cut and paste the code into a blank
text document, save it as a file with the .lsp extension, load it into
Autocad using appload or drag & drop the new file into the Acad session.
Then just type deletelayerents at the command line and follow the prompts.

Jeff

[code]
;;routine to find and delete items on a specified layer,
;; including within all block definitions
;; Jeff Mishler March 2007
;; Make sure the desired layer is NOT locked prior to use or it will fail.
(defun c:deletelayerents (/ doc kwrd lay lst wrd)
(defun findobjonlayer (layer / result)
(vl-load-com)
(if (not (tblsearch "LAYER" layer))
(princ "Layer does not exist.")
(progn
(vlax-for blk
(vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(vlax-for ent blk
(if (eq (strcase (vla-get-layer ent)) (strcase layer))
(setq result (cons (cons ent (vla-get-name blk)) result))
)
(if (and (eq (vla-get-objectname ent) "AcDbBlockReference")
(eq (vla-get-hasattributes ent) :vlax-true)
)
(foreach att (vlax-invoke ent 'getattributes)
(if (eq (strcase (vla-get-layer att)) (strcase layer))
(setq
result (cons (cons att (vla-get-name blk)) result)
)
)
)
)
)
)
)
)
result
)
(if (setq lay (getstring "\nLayer name to find objects on: "))
(progn
(if (setq lst (findobjonlayer lay))
(progn
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark doc)
(princ (strcat (itoa (length lst))
" entities found on layer "
lay
"."
)
)
(initget "All One None")
(setq kwrd
(getkword "\nDelete them all?[All/One_at_a_time/None]: "
)
)
(cond
((= kwrd "All")
(mapcar '(lambda (x)
(vla-delete (car x))
)
lst
)
)
((= kwrd "One")
(foreach ent lst
(initget "Yes No")
(setq
wrd (getkword (strcat "/nDelete "
(vla-get-objectname (car ent))
" in block "
(cdr ent)
"?:[Yes/No] "
)
)
)
(if (eq wrd "Yes")
(vla-delete (car ent))
)
)
)
(t nil)
)

(vla-endundomark doc)
)
)
)
)
(princ)
)
[/code]


wrote in message news:5517392@discussion.autodesk.com...
Theres some girls up in drafting that are hip to lisp routines. I can print
out what you posted and ask them if it makes sense, thanks again.
Message 13 of 23
Anonymous
in reply to: Anonymous

Hey Jeff you're awesome.

My friend came down to show me how to load a lisp into CAD and this command worked.

I am just a lowly surveyor, I bow down to the smarties who know this stuff~ Thanks very much
Message 14 of 23
Anonymous
in reply to: Anonymous

You're welcome, I'm glad it worked for you. I was goig to post another
followup letting you know that if the layer still wouldn't purge, then it is
probably referenced by a dimstyle's settings. So just remember that for
future tasks.

And FWIW, I'm a surveyor, too. I've just been around this software a long
time.

wrote in message news:5517403@discussion.autodesk.com...
Hey Jeff you're awesome.

My friend came down to show me how to load a lisp into CAD and this command
worked.

I am just a lowly surveyor, I bow down to the smarties who know this stuff~
Thanks very much
Message 15 of 23
Anonymous
in reply to: Anonymous

Anyone else find it strange that laydel isn't working? Wasn't laydel created
because of these reference issues? I have seen that error with C3D and I
kind of expect it in C3D with the way the layers & the object styles are
working. I have used laydel in LDT dwg's for years w/o any issue. Has anyone
else run into this?

Please do not take this wrong algrrl. I do believe you. I am just the
curious type. If you do find what object is creating the problem please post
back & let us know.


--
John Mayo
Project Engineer
Conklin Associates
Ramsey, NJ

Civil 3D 2007, LDT 2007, Raster Design 2007
P-IV at 3.5 GHz
2 GB Ram
Nvidea Quadro FX w/ 128 MB Ram
wrote in message news:5517310@discussion.autodesk.com...
Express tool Layer Delete won't delete the layer, says it's being referenced
by an object.
Message 16 of 23
Anonymous
in reply to: Anonymous

Just FYI, another way around this issue is to use Layer Merge in Express
tools. Thus if the layer (BO) was being used by a block, you could merge the
layer (BO) to layer 0 (where it should be) and then the layer would be free
for purging. The lisp routine would still be a better solution.

wrote in message news:5517146@discussion.autodesk.com...
Using 2004 right now (2007 is kicking my butt)

I just want to delete layer B0.

Express tool Layer Delete won't delete the layer, says it's being referenced
by an object.

Layer walk tells me there is 1 object on this layer.

I'm assuming it's being used in a block somewhere, because there are no
visible objects on B0 when I isolate it.

How can I find this block? I thought Layer Walk would help me do that,
maybe I don't know how the command works or something.

Thanks--
Message 17 of 23
Anonymous
in reply to: Anonymous

I thought the Layer Name in question here was BO also Neil, until I did a
little further investigation and discovered it was actually B0.

Before I discovered that, I was thinking somebody was maybe exercising their
comedic tendencies in this particular situation?

BO = BodyOrder 😞

--
Don Reichle
"The only thing worse than training your staff, and having them leave is -
not training your staff, and having them stay." 😮
A reminder taken from Graphics Solution Providers' Calendar page
--------------------------------------------------------------------
!! Please discuss whatever we tell you with your SysMgr !!
!! They appreciate staying in the loop 🙂 !!

C3D/LDT/CD-2K7 SP2A
AMD Athlon64 2.2GHz 2GB RAM
XPPro 32bit SP2
WD Raptor 10K-rpm 37GB HD
Nvidia GeForce FX 5200 128MB

"The only Constant is Change".


"neilw" wrote in message
news:5518940@discussion.autodesk.com...
Just FYI, another way around this issue is to use Layer Merge in Express
tools. Thus if the layer (BO) was being used by a block, you could merge the
layer (BO) to layer 0 (where it should be) and then the layer would be free
for purging. The lisp routine would still be a better solution.

wrote in message news:5517146@discussion.autodesk.com...
Using 2004 right now (2007 is kicking my butt)

I just want to delete layer B0.

Express tool Layer Delete won't delete the layer, says it's being referenced
by an object.

Layer walk tells me there is 1 object on this layer.

I'm assuming it's being used in a block somewhere, because there are no
visible objects on B0 when I isolate it.

How can I find this block? I thought Layer Walk would help me do that,
maybe I don't know how the command works or something.

Thanks--
Message 18 of 23
Anonymous
in reply to: Anonymous

Hi Jeff,

this is very cool routine. It would be even more helpful if one could just select an entity on a layer and all the entities on that layers would be deleted. Would that be much of an effort for you to add this piece of code? thanks in any case. Strah
Message 19 of 23
Anonymous
in reply to: Anonymous

Nope, pretty simple. Most of the code is in that one. If I have some time
tomorrow I'll see what I can do. Or, HEY, DON! This would be a good one for
you take a stab at modifying. 🙂

(Hint: Strip out all of the stuff asking questions for the user to answer,
add code to select an object and get it's layer.....)

wrote in message news:5520286@discussion.autodesk.com...
Hi Jeff,

this is very cool routine. It would be even more helpful if one could just
select an entity on a layer and all the entities on that layers would be
deleted. Would that be much of an effort for you to add this piece of code?
thanks in any case. Strah
Message 20 of 23
Anonymous
in reply to: Anonymous

Hi strah,

A routine that automatically deletes entites sounds dangerous. Why not have
a routine that tells you what is conflicintng and then give you a choice?

wrote in message news:5520286@discussion.autodesk.com...
Hi Jeff,

this is very cool routine. It would be even more helpful if one could just
select an entity on a layer and all the entities on that layers would be
deleted. Would that be much of an effort for you to add this piece of code?
thanks in any case. Strah

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report