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.