+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default Select specified layer Objects and delete

    Registered forum members do not see this ad.

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

  2. #2
    Full Member
    Computer Details
    LanloyLisp's Computer Details
    Operating System:
    Window 7 Premium
    Using
    AutoCAD 2013
    Join Date
    Jun 2013
    Location
    La Union, Philippines
    Posts
    34

    Default

    Command: LAYMRG


    Give it a try..

  3. #3
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,124

    Default

    Not tested:

    Code:
    (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)

  4. #4
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default

    grrr thank you very much. it is working.
    can you provide selecting objects only? instead of delete.

    Thank you.

  5. #5
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,124

    Default

    Quote Originally Posted by Raje View Post
    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) :
    Code:
    (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)
    )

  6. #6
    Full Member
    Computer Details
    LanloyLisp's Computer Details
    Operating System:
    Window 7 Premium
    Using
    AutoCAD 2013
    Join Date
    Jun 2013
    Location
    La Union, Philippines
    Posts
    34

    Default

    Quote Originally Posted by LanloyLisp View Post


    Give it a try..
    My bad.. I thought you want to delete the layer itself..

  7. #7
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default

    Grrr thank you, it is also worked fine.

  8. #8
    Full Member
    Discipline
    Structural
    Using
    AutoCAD 2013
    Join Date
    Oct 2017
    Posts
    27

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by LanloyLisp View Post
    My bad.. I thought you want to delete the layer itself..
    LOL its ok and thank you..

Similar Threads

  1. Select objects to new Layer
    By jyan2000 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 6th Jun 2017, 09:23 pm
  2. Select all objects in a single layer: how?
    By Sudan in forum AutoCAD Beginners' Area
    Replies: 11
    Last Post: 15th Sep 2015, 08:21 pm
  3. Select All Objects on a Certain Layer
    By resullins in forum AutoCAD General
    Replies: 4
    Last Post: 28th Dec 2011, 01:22 am
  4. Replies: 0
    Last Post: 27th May 2011, 11:30 pm
  5. Can't select objects to delete them(layer not frozen or locK
    By NathanSF in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 2nd Feb 2006, 05:44 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts