Skip to main content
2 of 5
added 126 characters in body
Marty Fouts
  • 33.5k
  • 10
  • 37
  • 80

Here is an example of how to use an override to allow you to invoke apply_pose_asset:

import bpy

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
region = [region for region in assets[0].regions if region.type == 'TOOLS']

override = {
    'window': win,
    'screen': scr,
    'area'  : assets[0],
    'region': region[0],
    'scene' : bpy.context.scene,
}


bpy.ops.poselib.apply_pose_asset(override)

The override argument takes the form of a Python dictionary. Each entry represents one piece of context to override. The above example shows the complete override for the command. Note that the area type is FILE_BROWSER. That is the area type of the editor window that the command expects to run in. It's really the only thing you need to override in this case, so the code could be shortened to

assets = [area for area in bpy.context.screen.areas if area.type == 'FILE_BROWSER']
bpy.ops.poselib.apply_pose_asset({'area': assets[0]})

This assumes that there is either only one asset manager editor window open or that if there are more, the first one is the one you want.

Note: The command itself uses the first valid entry in the catalog if none are selected, or the active entry if one is selected.

Marty Fouts
  • 33.5k
  • 10
  • 37
  • 80