Jump to content
Raje

Select specified layer Objects and delete

Recommended Posts

Raje

Hii,

i have layer names like "Earth Line'", "Steel Line", "Concrete Line" etc..

so i need select all mentioned layer named containing objects and delete them.

any code for this task?

 

Thankyou..

Share this post


Link to post
Share on other sites
LanloyLisp
Command: LAYMRG
:roll:

 

Give it a try..

Share this post


Link to post
Share on other sites
Grrr

Not tested:

 

(defun C:test ( / acDoc SS )
 (cond
   ( (not (ssget "X" '((8 . "Earth Line',Steel Line,Concrete Line")))) (prompt "\nNo Selection.") )
   ( (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
     (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)
     (vlax-map-collection (setq SS (vla-get-ActiveSelectionSet acDoc)) ''((x) (vl-catch-all-apply 'vla-Delete (list x))))
     (vla-Delete SS)
     (vla-EndUndoMark acDoc)
   )
 )
 (princ)
)
(vl-load-com)(princ)

Share this post


Link to post
Share on other sites
Raje

grrr thank you very much. it is working.

can you provide selecting objects only? instead of delete.

 

Thank you.

Share this post


Link to post
Share on other sites
Grrr
grrr thank you very much. it is working.

can you provide selecting objects only? instead of delete.

 

Thank you.

 

Thanks for confirming,

This should limit the selection to the active viewport (as my previous suggestion selects objects in all viewports - and that might be unwanted) :

(defun C:test nil 
 (sssetfirst nil
   (ssget "X" 
     (list 
       '(8 . "Earth Line',Steel Line,Concrete Line") 
       (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model"))
     )
   )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
LanloyLisp
:roll:

 

Give it a try..

 

My bad.. I thought you want to delete the layer itself..:geek:

Share this post


Link to post
Share on other sites
Raje

Grrr thank you, it is also worked fine.

Share this post


Link to post
Share on other sites
Raje
My bad.. I thought you want to delete the layer itself..:geek:

 

LOL its ok and thank you..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×