# How to set a random value for only visible shape keys?

My question is related to my previous asked one: How to set a random value for multiple shape keys?

I want to set the random values for only visible shapekeys. Is it possible using scripting?

I would also like to know how to set a specific value (like 0.5) for all visible shape keys.

import bpy
from random import uniform
context = bpy.context
obj = context.object

def set_shapekeys(obj, value=0.5, random=False):
sk = obj.data.shape_keys
for i, kb in enumerate(sk.key_blocks.values()):
if not i or kb.mute:
# assume kb[0] is 'Basis'
continue
if random:
kb.value = uniform(kb.slider_min, kb.slider_max)
else:
kb.value = value

#set visible keys to random

set_shapekeys(obj, random=True)

#set visible keys to 0.7

#set_shapekeys(obj, value=0.7)


Use set_shapekeys(obj, value=0.5) to set all visible shapekeys to 0.5

• WOW! Thank you so very much!!! Scripting is a black magic for me :). Really appreciate your help! – Paul Gonet Oct 22 '15 at 20:51