import bpy from bpy import data as D ob = D.objects['boom_hairs_group_ref'] ob.hide_viewport = not ob.hide_viewport