Jump to content

Lisp help - delete all objects on 4 layers but exclude blocks


loveboatcaptain

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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