Mask modifier - invert_vertex_group

Please advise what I am doing wrong. I’m trying to invert vertex group for all scene objects which have a Mask modifier named ‘hidden’

[OBJS.modifiers["hidden"].invert_vertex_group = False for OBJS in [m for m in bpy.context.scene.objects if m.type == 'MESH']]
File "<blender_console>", line 1
    [OBJS.modifiers["hidden"].invert_vertex_group = False for OBJS in [m for m in bpy.context.scene.objects if m.type == 'MESH']]
                                                                                                                           ^
SyntaxError: invalid syntax

There might be a better way ,but this works.

import bpy

MOD_NAME = 'hidden'

MSH_OBJS = [m for m in bpy.context.scene.objects if m.type == 'MESH']

for OBJS in MSH_OBJS:
	for MSK_MODS in OBJS.modifiers:   
		if MSK_MODS.type == 'MASK' and MSK_MODS.name == MOD_NAME:   
			MSK_MODS.invert_vertex_group = False
1 Like

Thanks again :slight_smile: