Jump to content

Select specified layer Objects and delete


Raje

Recommended Posts

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..

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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)
)

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...