Skip to main content
added 302 characters in body
Source Link
Marty Fouts
  • 33.5k
  • 10
  • 37
  • 80

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }
        bpy.ops.poselib.apply_pose_asset(override, blend_factor=1, flipped=False)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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


bpy.ops.poselib.apply_pose(pose_index=- 1) is currently an operator designed for the deprecated (but still functional) separate version of the Pose Library system, soon to be removed post Blender 3.1. It exists in the Properties sidebar as a tab in Armature's settings. It requires its own pose entries and 'PROPERTIES' area type context to be executed. Like so:

import bpy
bpy.ops.poselib.apply_pose({'area':'PROPERTIES'}, pose_index=0)

3.2 Update

Context overrides are deprecated in Blender 3.2 and are scheduled to be removed in Blender 3.3 The replacement is temp_override. The manual has examples of how to use the new function.

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }
        bpy.ops.poselib.apply_pose_asset(override, blend_factor=1, flipped=False)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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


bpy.ops.poselib.apply_pose(pose_index=- 1) is currently an operator designed for the deprecated (but still functional) separate version of the Pose Library system, soon to be removed post Blender 3.1. It exists in the Properties sidebar as a tab in Armature's settings. It requires its own pose entries and 'PROPERTIES' area type context to be executed. Like so:

import bpy
bpy.ops.poselib.apply_pose({'area':'PROPERTIES'}, pose_index=0)

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }
        bpy.ops.poselib.apply_pose_asset(override, blend_factor=1, flipped=False)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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


bpy.ops.poselib.apply_pose(pose_index=- 1) is currently an operator designed for the deprecated (but still functional) separate version of the Pose Library system, soon to be removed post Blender 3.1. It exists in the Properties sidebar as a tab in Armature's settings. It requires its own pose entries and 'PROPERTIES' area type context to be executed. Like so:

import bpy
bpy.ops.poselib.apply_pose({'area':'PROPERTIES'}, pose_index=0)

3.2 Update

Context overrides are deprecated in Blender 3.2 and are scheduled to be removed in Blender 3.3 The replacement is temp_override. The manual has examples of how to use the new function.

Corrected a small mistake in the code and added an answer to the original question at the end
Source Link

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }
        bpy.ops.poselib.apply_pose_asset(override, pose_index=-blend_factor=1, 1flipped=False)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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


bpy.ops.poselib.apply_pose(pose_index=- 1) is currently an operator designed for the deprecated (but still functional) separate version of the Pose Library system, soon to be removed post Blender 3.1. It exists in the Properties sidebar as a tab in Armature's settings. It requires its own pose entries and 'PROPERTIES' area type context to be executed. Like so:

import bpy
bpy.ops.poselib.apply_pose({'area':'PROPERTIES'}, pose_index=0)

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }
        bpy.ops.poselib.apply_pose_asset(override, pose_index=- 1)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }
        bpy.ops.poselib.apply_pose_asset(override, blend_factor=1, flipped=False)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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


bpy.ops.poselib.apply_pose(pose_index=- 1) is currently an operator designed for the deprecated (but still functional) separate version of the Pose Library system, soon to be removed post Blender 3.1. It exists in the Properties sidebar as a tab in Armature's settings. It requires its own pose entries and 'PROPERTIES' area type context to be executed. Like so:

import bpy
bpy.ops.poselib.apply_pose({'area':'PROPERTIES'}, pose_index=0)
added 91 characters in body
Source Link
Marty Fouts
  • 33.5k
  • 10
  • 37
  • 80

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }

 
        bpy.ops.poselib.apply_pose_asset(override, pose_index=- 1)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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.

EDIT: pointed out in a comment: my code needed some error handling and I didn't demonstrate how to use an override with arguments.

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

win = bpy.context.window
scr = win.screen
assets = [area for area in scr.areas if area.type == 'FILE_BROWSER']
if len(assets):
    region = [region for region in assets[0].regions if region.type == 'TOOLS']
    if len(region):
        override = {
            'window': win,
            'screen': scr,
            'area'  : assets[0],
            'region': region[0],
            'scene' : bpy.context.scene,
        }
        bpy.ops.poselib.apply_pose_asset(override, pose_index=- 1)
    else:
        print("Current Pose Library does not have a tools menu open.")
else:
    print("There is no Pose LIbrary open.")

The override is inserted into the function call as the first argument, all other arguments remaining the same.

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.

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

added 126 characters in body
Source Link
Marty Fouts
  • 33.5k
  • 10
  • 37
  • 80
Loading
Source Link
Marty Fouts
  • 33.5k
  • 10
  • 37
  • 80
Loading