diff --git a/space_view3d_modifier_tools.py b/space_view3d_modifier_tools.py index ef3120729..9dcabb99d 100644 --- a/space_view3d_modifier_tools.py +++ b/space_view3d_modifier_tools.py @@ -34,23 +34,19 @@ class ApplyAllModifiers(Operator): is_select = True # copying context for the operator's override - contx = bpy.context.copy() - contx['object'] = obj + context_override = {'object': obj} modifiers = modifier_type(obj) for mod in modifiers[:]: - contx['modifier'] = mod + context_override['modifier'] = mod is_mod = True try: - bpy.ops.object.modifier_apply( - contx, - modifier=contx['modifier'].name - ) - - bpy.ops.object.gpencil_modifier_apply( - modifier=contx['modifier'].name - ) + with bpy.context.temp_override(**context_override): + if obj.type != 'GPENCIL': + bpy.ops.object.modifier_apply(modifier=mod.name) + else: + bpy.ops.object.gpencil_modifier_apply(modifier=mod.name) except: obj_name = getattr(obj, "name", "NO NAME") collect_names.append(obj_name)