Skip to content
Snippets Groups Projects
Commit 6cd3a735 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Pose Library: use functions instead of operators to mark/clear asset

Replace `ASSET_OT_mark` and `ASSET_OT_clear` operator calls with calls to
resp. `ID.asset_mark()` and `ID.asset_clear()`.

No functional changes.
parent aec02fd0
No related branches found
No related tags found
No related merge requests found
......@@ -21,34 +21,11 @@ Pose Library - functions.
"""
from pathlib import Path
from typing import Any, List, Set, cast, Iterable
from typing import Any, List, Iterable
Datablock = Any
import bpy
from bpy.types import (
Context,
)
def asset_mark(context: Context, datablock: Any) -> Set[str]:
asset_mark_ctx = {
**context.copy(),
"id": datablock,
}
return cast(Set[str], bpy.ops.asset.mark(asset_mark_ctx))
def asset_clear(context: Context, datablock: Any) -> Set[str]:
asset_clear_ctx = {
**context.copy(),
"id": datablock,
}
result = bpy.ops.asset.clear(asset_clear_ctx)
assert isinstance(result, set)
if "FINISHED" in result:
datablock.use_fake_user = False
return result
def load_assets_from(filepath: Path) -> List[Datablock]:
......
......@@ -216,7 +216,9 @@ class POSELIB_OT_copy_as_asset(PoseAssetCreator, Operator):
filepath = self.save_datablock(asset)
functions.asset_clear(context, asset)
# The asset has been saved to disk, so to clean up it has to loose its asset & fake user status.
asset.asset_clear()
asset.use_fake_user = False
if asset.users > 0:
self.report({"ERROR"}, "Unexpected non-null user count for the asset")
return {"FINISHED"}
......
......@@ -305,7 +305,7 @@ def create_pose_asset(
) -> Optional[Action]:
"""Create a single-frame Action containing only the pose of the given bones.
DOES mark as asset, DOES NOT add asset metadata.
DOES mark as asset, DOES NOT configure asset metadata.
"""
creator = PoseActionCreator(params)
......@@ -313,7 +313,7 @@ def create_pose_asset(
if pose_action is None:
return None
functions.asset_mark(context, pose_action)
pose_action.asset_mark()
return pose_action
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment