I'd like to toggle the Mirror modifier of selected object. I always do weight paint without the Mirror modifier but I have to check the mirrored half part sometimes. This script works fine but it is not so good.
objname = bpy.context.active_object.name
bpy.data.objects[objname].modifiers["User Defined Modifier Name"].show_viewport = not bpy.data.objects[objname].modifiers["User Defined Modifier Name"].show_viewport
This can toggle modifier with modifier name "User Defined Modifier Name" of active object but I need to pre-define modifier name to work it correctly. What I'd like to do is like this. I want to toggle all Mirror modifiers of currently selected objects.
objname = bpy.context.active_object.name
for modifier in bpy.data.objects[objname].modifiers:
if modifier.type == "MIRROR":
if modifier == False:
modifier = True
else
modifier = False
of course it does not work because I need to use this format to disable Mirror modifier.
bpy.data.objects[objname].modifiers["User Defined Modifier Name"].show_viewport
but I don't know how to get modifier name. Do you know how to get modifier name?
obj = context.object
thenbpy.data.objects[obj.name]
isobj
there is really no need to get the name from the object then get the object via the name. $\endgroup$