Jump to content

Selecting Multiple Blocks with Different Block Names


Bobzy20

Recommended Posts

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
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 2 years later...
On 11/14/2019 at 12:55 PM, SLW210 said:

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

This is brilliant way but i can’t fill value space. And i can’t see ‘smart solid’

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