Adding the Collision Modifier to several objects via script

Hey guys, Python-noob here :smiley:

I hav a bunch of objects that I want to add the collision modifier to. I tried this:

for i in bpy.data.objects:
if i.name.startswith(“Objectname”):
# Select object:
bpy.ops.object.select_pattern(pattern=i.name)
# Add modifier:
bpy.ops.object.modifier_add(type=‘COLLISION’)

which I got from another thread on here. The problem now is, that this only adds the collision to ONE object, which is the active one. Can you think of a way to actually go through all the objects (they are all on the same seperate layer btw) and add the Collision Modifier to one after the other?

Thank you so much :slight_smile:

-NEMO

is this for an existing addon by any chance?

Yeah, man, thanks for the hint! Found one :slight_smile: <3