Jump to content

Recommended Posts

Posted

Hi!

 

I've just saw this thread regarding layer deletion:

 

http://www.cadtutor.net/forum/showthread.php?t=2022

 

Can someone help me on how to modify this small application in a way that I don't need to selec the layer to delete using the mouse button, but rather stating the layer to delete at the command line.

 

Thanks !

Posted

How is that any different from using Express Tools > Layer Delete and the Type-it option?

Posted

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

Posted

Wouldn't a one line macro that pauses for the layer name accomplish the same thing?

Posted
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?
Posted

I just completed the request of the OP...

 

But I would agree that a one line macro would be better.

Posted

Short and sweet is the way I would go. Why do we sometimes like to make things more complicated than they have to be?

Posted

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

Posted
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

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