"Select" and "select exclude" objects by name

Is there a way to select all objects, except some, by name? For example, I want to select and delete all, except objects named "important_object_001", "important_object_002", "important_object_003". How should I do this?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

(
	objToSkipArr = #("important_object_001", "important_object_002", "important_object_003")
 
	objsToDel = for o in objects where (findItem objToSkipArr o.name) == 0 collect o
	delete objsToDel	
)
chooj's picture

thanx! A little bit tricky

thanx! A little bit tricky for me, but I will try to understand )

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.