2
$\begingroup$

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? enter image description here

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

$\endgroup$

1 Answer 1

2
$\begingroup$
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

$\endgroup$
1
  • $\begingroup$ WOW! Thank you so very much!!! Scripting is a black magic for me :). Really appreciate your help! $\endgroup$
    – Paul Gonet
    Oct 22, 2015 at 20:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .