Im trying to check if the selected object has a specific modifier, adding the modifier if it doesn't exist, and then applying all the modifiers:
import bpy obj = bpy.context.object modifs=[] for modifier in obj.modifiers: modifs.append(modifier.type) if 'TRIANGULATE' not in modifs:] bpy.ops.object.modifier_add(type='TRIANGULATE') for modif in modifs: bpy.ops.object.modifier_apply(apply_as='DATA', modifier=modif) Code above adds the modifier if it isn't present but it doesn't apply the modifiers to the object. If I paste bpy.ops.object.modifier_apply(apply_as='DATA', modifier=modif) into the python console it applies the modifier. What am I doing wrong?