Page MenuHome

Default Shape Key ID in Keying Set files broken - TypeError: 'builtin_function_or_method' object is not subscriptable
Closed, ResolvedPublic

Description

System Information
Windows 10

Blender Version
Broken: 2.78c, 2.79 rc1
Worked: N/A

Issue is the following:

I've found that the default Keying set that Blender exports from the Keying Set Panel, when you have shape keys added to the keyset - will pull the following error and be useless:

TypeError: 'builtin_function_or_method' object is not subscriptable
Error: Python script fail, look in the console for now...

The solution is changing the shape key ID to the correct one:

# Keying Set: KeyingSet
import bpy

scene = bpy.context.scene

# Keying Set Level declarations
ks = scene.keying_sets.new(idname="KeyingSet", name="Keyset_Name")
ks.bl_description = ""

ks.use_insertkey_needed = False
ks.use_insertkey_visual = False
ks.use_insertkey_xyz_to_rgb = True

# ID's that are commonly used

## This is the default in blender, and it is broken. 
#id_0 = bpy.types.key["Key"]

### Use this instead:
id_0 = bpy.context.object.data.shape_keys

# Path Definitions
ksp = ks.paths.add(id_0, 'key_blocks["Shape_Name"].value', index=-1)

Exact steps for others to reproduce the error

  1. Create a Shape key
  2. Create a Keying Set
  3. Select Shapekey value and then add to active Keying Set
  4. Export Keyingset
  5. Load python Keyingset and append object with shape key
  6. Run
  7. Error