Jump to content
Bobzy20

Selecting Multiple Blocks with Different Block Names

Recommended Posts

Bobzy20

We often get drawings drawn using MicroStation and then exported to DWG and we have hundreds of blocks within the drawing that have slightly different block names, albeit they are the same block.

 

Block Name: "Smart Solid_386"       (The number on the end '386' changes).

 

There are hundreds of these blocks within our drawings and I what a way of selecting all of them and deleting.

 

I can’t seem to find a way of using ‘Quick Select’ to do it and not sure exactly how ‘Filter’ could be used?

 

Probably an easy question for somebody, as I’m sure it’s come up before but I can’t seem to find the answer.

 

Any help would be great.

 

Bob

Edited by Bobzy20

Share this post


Link to post
Share on other sites
tombu

The lisp 

(sssetfirst nil (ssget "X" '((0 . "INSERT")(2 . "Smart Solid_*")))

should do it.

The FILTER command does this nicely as well using "Block Name = Smart Solid_*" and has the advantage of being able to save as a Named Filter that can be used in other drawings as well. I used FILTER a lot when I started in r12 over a quarter century ago.

 

Nothing I hate worse than having to clean up a drawing converted from Microstation.  Good Luck!

Share this post


Link to post
Share on other sites
Bobzy20

Thanks.

 

I have attached a sample drawing for you try your script on and also to try the Filter option. Also if you look at the CT.jpg screenshot attached, i have selected the block i want to be removed. Its the block that sits in the middle of the main light block although i think they share a similar name! However the block i want to be removed has another block inside that with a different name, maybe we could use this block name to remove them?

 

Sorry its confusing!

 

CT-1.thumb.jpg.db08823dec66194ac31f3346733eaf64.jpg

CT.dwg

Share this post


Link to post
Share on other sites
tombu

Sorry I left off the closing parenthes is on the code above, updated it after testing it on your attached CT.dwg.

I've attached a clean version with the blocks deleted, had to purge blocks twice because of the blocks referenced by the other blocks.

CTclean.dwg

Share this post


Link to post
Share on other sites
Bobzy20

Thanks, how would i run that code?

 

What would i type after loading?

Share this post


Link to post
Share on other sites
tombu
9 minutes ago, Bobzy20 said:

Thanks, how would i run that code?

 

What would i type after loading?

Copy and Paste the code to the command line and enter to display all those blocks selected.  Using a saved filter should work as well, but the selection set will not display selected.  Just start ERASE and Enter L (Last) at the "Select objects:" prompt, then Enter again.

Share this post


Link to post
Share on other sites
BIGAL

Maybe not tested.

 

(setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2  (getstring "Type block names")))))

you can type solid_mesh*,solid-face*,solid-red* etc so multiple block names in one go

type Erase !ss <enter>

 

Edited by BIGAL

Share this post


Link to post
Share on other sites
SLW210

QSELECT>Block Reference>Name>*Wildcard Match>Smart Solid*

  • Thanks 1

Share this post


Link to post
Share on other sites
tombu
12 minutes ago, SLW210 said:

QSELECT>Block Reference>Name>*Wildcard Match>Smart Solid*

Completely forgot about the "* Wildcard Match" Operator.

 

That would definitely be the easiest way!

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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