thibaud-d of BlenderBox
10/10/2014 - 5:05 AM

Switch named modifiers ON or OFF. A typical use is with performance intensive modifiers you'd rather turn off while working/previewing resul

Switch named modifiers ON or OFF. A typical use is with performance intensive modifiers you'd rather turn off while working/previewing results. Note that each modifier has a name attached to it. The name of the modifier is not the same as the modifier type.


# Check all objects and switch the state of the
# specified, named modifiers
# ============================================
NAMES = ["S0","S1","S2","voronoi","Decimate"]
USE   = 1
# ============================================

import bpy

# ---------------------------------------------
print("Switch modifier state.")
# ---------------------------------------------

for obj in bpy.context.scene.objects:
    if len(obj.modifiers)<1: continue
    print(obj.name)    
    for k in obj.modifiers:
        if k.name in NAMES:
            k.show_viewport = USE
 
# ---------------------------------------------
print("All modifiers set to "+str(USE))
# ---------------------------------------------

# Copyright TEA DE SOUZA 2014. Free to use and
# modify, do not remove this notice.