Jump to content

Delete layer command


organetic

Recommended Posts

Since you asked :

 

(defun c:del-layer (/ ent l_name ss cntr amt ssent) 

;;; 
;;; erases all objects on selected layer then purges that layer 
;;; 

 (setvar 'clayer "0") ; set layer to 0 

 (if 
   ; make sure we get something 
   (and (setq l_name (getstring "\nSpecify Layer Name: "))
    (tblsearch "Layer" l_name)) ; test 
   (progn  
     ; create a selection set of all entites on layer 'l_name' 
     (setq ss (ssget "X" (list (cons 8 l_name))) 
           ; set 'cntr' to number of items in selection set 
           cntr (1- (sslength ss)) 
           amt (itoa cntr); make a string from an integer 
           ) 

     (if 
       ; does the sel set have anything in it 
       (> cntr 0); test 

       (while 
         ; as long as 'cntr' is greater than or equal to 0 
         ; keep looping 
         (>= cntr 0) 

         ; extract the ename from the sel set 
         (setq ssent (ssname ss cntr)) 
         (entdel ssent); delete that entity 
         (setq cntr (1- cntr)); subtract 1 from cntr 
         ) 

       ) 
     ) 
   ) 
 (command "_.purge" "LA" l_name "N") 
 (princ (strcat "\nErased " amt " items")) 
 (princ) 
 ) 

Link to comment
Share on other sites

How is that any different from using Express Tools > Layer Delete and the Type-it option?
I agree. Actually, I would prefer express tools, since LAYDEL will take care of nested objects as well. I don't think the LISP referenced by the OP does that, does it?
Link to comment
Share on other sites

I'm almost always one to fall into the trap of creating some huge code that could do the same thing as a one line macro...

 

Don't knock it. That probably explains why you're so good at it. I guess I'm more the "lazy drafter" type. LOL

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