Changeset View
Changeset View
Standalone View
Standalone View
pose_library/operators.py
| Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | class ASSET_OT_assign_action(Operator): | ||||
| def execute(self, context: Context) -> Set[str]: | def execute(self, context: Context) -> Set[str]: | ||||
| context.object.animation_data_create().action = context.id | context.object.animation_data_create().action = context.id | ||||
| return {"FINISHED"} | return {"FINISHED"} | ||||
| class POSELIB_OT_copy_as_asset(PoseAssetCreator, Operator): | class POSELIB_OT_copy_as_asset(PoseAssetCreator, Operator): | ||||
| bl_idname = "poselib.copy_as_asset" | bl_idname = "poselib.copy_as_asset" | ||||
| bl_label = "Copy Pose As Asset" | bl_label = "Copy Pose as Asset" | ||||
| bl_description = "Create a new pose asset on the clipboard, to be pasted into an Asset Browser" | bl_description = "Create a new pose asset on the clipboard, to be pasted into an Asset Browser" | ||||
| bl_options = {"REGISTER"} | bl_options = {"REGISTER"} | ||||
| CLIPBOARD_ASSET_MARKER = "ASSET-BLEND=" | CLIPBOARD_ASSET_MARKER = "ASSET-BLEND=" | ||||
| def execute(self, context: Context) -> Set[str]: | def execute(self, context: Context) -> Set[str]: | ||||
| asset = pose_creation.create_pose_asset_from_context( | asset = pose_creation.create_pose_asset_from_context( | ||||
| context, new_asset_name=context.object.name | context, new_asset_name=context.object.name | ||||
| Show All 35 Lines | def save_datablock(self, action: Action) -> Path: | ||||
| fake_user=True, | fake_user=True, | ||||
| compress=True, # Single-datablock blend file, likely little need to diff. | compress=True, # Single-datablock blend file, likely little need to diff. | ||||
| ) | ) | ||||
| return filepath | return filepath | ||||
| class POSELIB_OT_paste_asset(Operator): | class POSELIB_OT_paste_asset(Operator): | ||||
| bl_idname = "poselib.paste_asset" | bl_idname = "poselib.paste_asset" | ||||
| bl_label = "Paste As New Asset" | bl_label = "Paste as New Asset" | ||||
| bl_description = "Paste the Asset that was previously copied using Copy As Asset" | bl_description = "Paste the Asset that was previously copied using Copy As Asset" | ||||
| bl_options = {"REGISTER", "UNDO"} | bl_options = {"REGISTER", "UNDO"} | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context: Context) -> bool: | def poll(cls, context: Context) -> bool: | ||||
| if not asset_utils.SpaceAssetInfo.is_asset_browser(context.space_data): | if not asset_utils.SpaceAssetInfo.is_asset_browser(context.space_data): | ||||
| cls.poll_message_set("Current editor is not an asset browser") | cls.poll_message_set("Current editor is not an asset browser") | ||||
| return False | return False | ||||
| ▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines | |||||