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:
print(mod)
if mod.name == "MYMODIFIER": # or if "MYMODIFIER" in mod.name:
bpy.ops.object.modifier_remove( modifier = mod.name )
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:
print(mod)
if mod.name == “Solidify”:
bpy.ops.object.modifier_remove( modifier = mod.name )
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.