PianoMan Posted January 29, 2016 Share Posted January 29, 2016 Hi all! I'm trying to create a lisp that, when activated, will automatically select and delete all objects on several layers, ideally that are written into the lisp itself so I don't have to enter anything. Unfortunately, while I can make sense of code with time, I have a very limited understanding of what's out there, and don't know what commands I need to do what I want to do. I got a decent start with this code: (defun c:SALL () (setq TargetEnt (car (entsel "\nSelect object on layer to select: "))) (setq TargetLayer (assoc 8 (entget TargetEnt))) (sssetfirst nil (ssget "_X" (list TargetLayer))) (princ) ) taken from here, but I can't figure out how to have it automatically select items from specified layers, and adding an erase command at the end of the whole thing doesn't seem to work. If anyone could help me finish this, I would greatly appreciate it! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2016 Share Posted January 29, 2016 Welcome to CADTutor. Here is a very simple form of such a program: (defun c:delonlayer ( / i s ) (if (setq s (ssget "_X" '((8 . "[highlight]Layer1,Layer2,Layer3[/highlight]")))) (repeat (setq i (sslength s)) (entdel (ssname s (setq i (1- i))))) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
PianoMan Posted January 29, 2016 Author Share Posted January 29, 2016 Perfect! Thanks! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 29, 2016 Share Posted January 29, 2016 Maybe a command line version ? (defun delonlayer (lays / i s ) (if (setq s (ssget "_X" (List (cons 8 lays)))) (repeat (setq i (sslength s)) (entdel (ssname s (setq i (1- i))))) ) (princ) ) type this on command line (delonlayer ""Layer1,Layer2,Layer3") 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.