Select blocks with different names at the same time

Select blocks with different names at the same time

luigiverdenico
Enthusiast Enthusiast
3,173 Views
8 Replies
Message 1 of 9

Select blocks with different names at the same time

luigiverdenico
Enthusiast
Enthusiast

Hi all,

I have a format drawing where there are hundreds of blocks with different names.

Starting from this drawing, I have to leave just some dozens of these blocks (whose names are in an excel file), deleting others. My question is if it is possible to automate the operation through a command like "quick select" or a lisp able to select simultaneously unnecessary blocks (as an exclusion of the necessary ones shown in the excel file) so as to delete them quickly?

0 Likes
Accepted solutions (1)
3,174 Views
8 Replies
Replies (8)
Message 2 of 9

tramber
Advisor
Advisor

Use this piece of lisp code :

 

(setq ss (ssget  '((0 . "insert")(2 . "block1,block2,block3"))))
(sssetfirst nil ss)

Probably easy to do with Excel

 

"block1,

block2,

block3"


EESignature

0 Likes
Message 3 of 9

imadHabash
Mentor
Mentor

Hi,

>>My question is if it is possible to automate the operation 

till you find one ... i suggest to start now with QSELECT or SELECTSIMILAR command. 

 

Regards,

 

 

 

 

Imad Habash

EESignature

0 Likes
Message 4 of 9

tramber
Advisor
Advisor
(setq ss (ssget  '((0 . "insert")(-4 . "<NOT")(2 . "1,2,3")(-4 . "NOT>"))))
(sssetfirst nil ss)

Reversed, with the parameter NOT to exclude instead of including.


EESignature

Message 5 of 9

luigiverdenico
Enthusiast
Enthusiast

First of all thank you for the help. If I understand correctly, what you have reported is a part of the lisp code. Unfortunately I don't know about lisp so I can't complete it. Can you send me the complete file (you can call the  command "abaco"). Thank you.

0 Likes
Message 6 of 9

davinatkins
Advocate
Advocate

Since you don't know lisp - the other suggestion that was made should work well.

 

Click one of the blocks you want to erase (or several different if you wish) then right click and choose the select similar command. This will select all what that name (* options for this command may be different and not do this - but default mode does).  You can then just hit delete on the keyboard, or use the erase command.

 

It may take several uses of the command to get them all - but it's a sight easier than typing in all the names you wanted in a list.

0 Likes
Message 7 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

What type of blocks they are - dynamic or not?

 

IF your block are non-dynamic, use suggested LISP lines (below little simplified). There is really nothing to complete, just replace the dummy name with the real once delimited by comma and copy-paste the line into the command-line. That's all. As simple as it sounds, no more code needed.

 

Positive match:

(sssetfirst nil (ssget "_X" '((0 . "insert") (2 . "block1,block2,block3"))))

Negative match:

(sssetfirst nil (ssget "_X" '((0 . "insert")(-4 . "<NOT")(2 . "block1,block2,block3")(-4 . "NOT>"))))

If your blocks are dynamic, then a code has to be more advanced.

Message 8 of 9

tramber
Advisor
Advisor

well,.... my solution indeed !


EESignature

0 Likes
Message 9 of 9

ВeekeeCZ
Consultant
Consultant

@tramber wrote:

well,.... my solution indeed !


You had some good ideas that help me to provide a solution to the OP that helped him get the job done. Good job, @tramber !

0 Likes