loveboatcaptain Posted July 15, 2011 Share Posted July 15, 2011 Need a lisp to delete all objects on 4 different layers (ZZ-UKMAP-LANDLINE,ZZ-UKMAP-RAIL,ZZ-UKMAP-STATION,ZZ-UKMAP-STATION NAME). The only problem is that I have a block named “MAP” which I want to remain, this block has objects in it on the above layers. So want to delete all objects on four separate layers but exclude the block “MAP” (or exclude all blocks if easier). Can anyone help? I have been tryin to do this with ssget, but cannot write the lisp successfully, Thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 15, 2011 Share Posted July 15, 2011 check this out .. (defun c:test (/ ss i sset e) (if (setq ss (ssget "_x" '((8 . "ZZ-UKMAP-LANDLINE,ZZ-UKMAP-RAIL,ZZ-UKMAP-STATION,ZZ-UKMAP-STATION NAME")))) (repeat (setq i (sslength ss)) (setq sset (ssname ss (setq i (1- i)))) (setq e (entget sset)) (if (not (eq (cdr (assoc 2 e))"MAP")) (entdel sset) ) ) (princ) ) (princ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 15, 2011 Share Posted July 15, 2011 If the "MAP" block is not dynamic, this is how I would approach: (defun c:FOO (/ ss) (if (setq ss (ssget "_x" '((-4 . "<NOT") (2 . "MAP") (-4 . "NOT>") (8 . "ZZ-UKMAP-LANDLINE,ZZ-UKMAP-RAIL,ZZ-UKMAP-STATION,ZZ-UKMAP-STATION NAME")))) (command "._erase" ss "") (prompt "\n** Nothing selected ** ")) (princ)) ** Untested, and written on my MacBook, I can test when I get to work ** Note - A layer check should be done, to ensure the layers are not locked first. ... Otherwise, I would step through the selection set using vlax-for, conditionally qualifying with the EffectiveName for blocks. HTH 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.