organetic Posted February 17, 2009 Share Posted February 17, 2009 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 ! Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 17, 2009 Share Posted February 17, 2009 How is that any different from using Express Tools > Layer Delete and the Type-it option? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2009 Share Posted February 17, 2009 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) ) Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 17, 2009 Share Posted February 17, 2009 Wouldn't a one line macro that pauses for the layer name accomplish the same thing? Quote Link to comment Share on other sites More sharing options...
uddfl Posted February 17, 2009 Share Posted February 17, 2009 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2009 Share Posted February 17, 2009 I just completed the request of the OP... But I would agree that a one line macro would be better. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2009 Share Posted February 17, 2009 Something like this: ^C^Claydel;T;\;Y; Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 18, 2009 Share Posted February 18, 2009 Short and sweet is the way I would go. Why do we sometimes like to make things more complicated than they have to be? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 18, 2009 Share Posted February 18, 2009 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... Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 18, 2009 Share Posted February 18, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.