def main():
name = "Cube"
c4d.CallCommand(100004766)
objList = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)
for obj in objList:
if obj.GetName().find(name) == int(-1):
doc.SetSelection(obj, c4d.SELECTION_SUB)
c4d.EventAdd
You can try this.
It is pretty shakey, but it will select any object that has the word “Cube” in the name.
You can change
name = "Cube"
to whatever you want to search for.
pretty much
name = "Cube"
is the search string
c4d.CallCommand(100004766)
selects everything in the scene
objList = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)
this builds a list from the selection
for obj in objList:
this loops through the list
if obj.GetName().find(name) == int(-1):
this looks to see if the search string is in the object name
doc.SetSelection(obj, c4d.SELECTION_SUB)
if the search string is NOT in the object name then the object is removed from the selection.
Again, there are probably cleaner ways of constructing this sort of process, but this one is the simplest I can think of.