How to remove modifier_001? syntax

Well, the following syntax removes the modifier’s subsurf.


But this is only the one with the name subsurf. That is, duplicate modifiers with _001 and _002 cannot be deleted.
I checked the syntax of python and checked api, but the * wildcard does not seem to work.
How can python be able to remove modifiers with _001 and _002 in their names? As with other objects, are regular expressions not supported?

list the obj.modifiers, match the names and delete the matching modifiers

This is how I did in the past

    for mod in obj.modifiers:
        if == "MYMODIFIER": # or if  "MYMODIFIER" in
          bpy.ops.object.modifier_remove( modifier = )

Make sure that the object is active since the ops operate on the current object.

thanks. I tried it but it doesn’t seem to work.
Next we did modifier solidify, but 001 and 002 remain.
Although the specification of obj may be wrong with the addition, it is not clear.

obj = context.active_object
for mod in obj.modifiers:
if == “Solidify”:
bpy.ops.object.modifier_remove( modifier = )

You need to pass the actual name like (modifier = “Solidify_001”) etc is literally is the name of the modifier not the type.

1 Like

Check the type if you want to remove all of the same type.

if mod.type == ‘SOLIDIFY’:
bpy.ops.object.modifer_remove(modifier =

Or use string pattern matching:


1 Like

Oh, it didn’t notice! Thank you for teaching me.
But as we will see later, we decided to deal with it in a way that might not be smart.
Thank you for the help.

Type specification and pattern matching feel like a good technique. Thank you for teaching me.
Unfortunately we couldn’t use it. Of course it is not that mistake.
I couldn’t put in a code that worked.
Thank you for the help.

Well, after all, I think that our code is not very clear.
The solution to this is this:


I just extend the numbers. 001,002,003,004,
I know, it is likely to be spaghetti code … =)