Access to shape keys by script

Hi everyone!!
do you know if is there any way to access to shape keys through script?

Working with more than 30 shape keys with the patch editor is a little confusing and tedious :grimacing:


I don’t have anything on hand, but I’m happy to take a look if you can post a tiny demo project.

1 Like

thanks for you response Josh! :pray:

here is a part of a project that I made with shape keys and patches.

It’s basically a balloon that goes from deinflated to inflated and goes flying.
the transition between deinflated to inflated was made with shape keys.

here is the filter link is you want to see it in action

Here’s how to get the blend shapes. You can loop through them and set the weight on each

import Scene from 'Scene';
import Diagnostics from 'Diagnostics';
const {log} = Diagnostics;

(async function () {

    const deflated = await Scene.root.findFirst('Corazon desinflado.003')
    const blendShapes = await deflated.getBlendShapes()

    blendShapes.forEach((blendShape, i) => {

BlendShape {
    The `BlendShape` class describes a shape attached to a mesh or face mesh which can be used to change the shape of that mesh.
    name: "frame_0000"
      (get) name: string
      (set) (Not Available)

      Retrieves the name of the BlendShape.
    weight: Object
      (get) weight: ScalarSignal
      (set) weight: ScalarSignal

      Specifies the weight of the blend shape.

Thank you Josh!!!
It’s works great!
Now I have to figure out how to set the duration between “frames” :grimacing: :grimacing:

thank you again Josh!!!

Hi @sebalarrain . Glad to know it works! I moved this topic to Spark AR Question and tag it with relevant tags. For now I’ll mark Josh answer as the solution. :beers:

1 Like