Fix: Regression of Python API for anim.keyframe_insert #117718

Merged
Christoph Lendenfeld merged 1 commits from ChrisLend/blender:fix_python_api_changes into main 2024-02-01 16:14:19 +01:00

Caused by #113504: Anim: Insert keyframes without keying sets

The type property has been removed from the operator, but of course that is a breaking change in 4.1.
(e.g. reported here: #117547: RBD Bake to Keyframes no longer working)

At the time of making the patch, I wasn't sure how to handle all cases but it turns out its not complicated.
I've added back the property with the following logic.

  • Try to get the KeyingSet from the type.
  • type defaults to 0 which means the ANIM_keyingset_get_from_enum_type will get it from the scene.
  • If the scene doesn't have one, or a valid index isn't passed in the KeyingSet will be a nullptr in which case it inserts from the user preferences.

One thing I was confused about at first is that the enum is passed in as a string from the python side, but received as an int on the C side.
I thought the difference between ANIM_OT_keyframe_insert and ANIM_OT_keyframe_insert_by_name is how the keying set name is passed.
But both take the exact same strings in python.


I am wondering if there is a way to deprecate a property so we can remove it in 5.0

Caused by [#113504: Anim: Insert keyframes without keying sets](https://projects.blender.org/blender/blender/pulls/113504) The `type` property has been removed from the operator, but of course that is a breaking change in 4.1. (e.g. reported here: [#117547: RBD Bake to Keyframes no longer working](https://projects.blender.org/blender/blender/issues/117547)) At the time of making the patch, I wasn't sure how to handle all cases but it turns out its not complicated. I've added back the property with the following logic. * Try to get the `KeyingSet` from the `type`. * `type` defaults to 0 which means the `ANIM_keyingset_get_from_enum_type` will get it from the scene. * If the scene doesn't have one, or a valid index isn't passed in the `KeyingSet` will be a `nullptr` in which case it inserts from the user preferences. One thing I was confused about at first is that the `enum` is passed in as a string from the python side, but received as an `int` on the C side. I thought the difference between `ANIM_OT_keyframe_insert` and `ANIM_OT_keyframe_insert_by_name` is how the keying set name is passed. But both take the exact same strings in python. ---- I am wondering if there is a way to deprecate a property so we can remove it in 5.0
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2024-02-01 11:39:12 +01:00
Christoph Lendenfeld added 1 commit 2024-02-01 11:39:24 +01:00
Sybren A. Stüvel approved these changes 2024-02-01 15:15:29 +01:00
Sybren A. Stüvel left a comment
Member

At the time of making the patch, I wasn't sure how to handle all cases but it turns out its not complicated.
I've added back the property with the following logic.

  • Try to get the KeyingSet from the type.
  • type defaults to 0 which means the ANIM_keyingset_get_from_enum_type will get it from the scene.
  • If the scene doesn't have one, or a valid index isn't passed in the KeyingSet will be a nullptr in which case it inserts from the user preferences.

LGTM.

One thing I was confused about at first is that the enum is passed in as a string from the python side, but received as an int on the C side.

That's how RNA deals with many enums. The name of the enum item is used in Python, and gets mapped to an integer on the C/C++ side. You can find many examples of this mapping when you search in the RNA code for EnumPropertyItem rna_.

I am wondering if there is a way to deprecate a property so we can remove it in 5.0

Not really, apart from documenting the property as deprecated in its tooltip / description.

> At the time of making the patch, I wasn't sure how to handle all cases but it turns out its not complicated. > I've added back the property with the following logic. > * Try to get the `KeyingSet` from the `type`. > * `type` defaults to 0 which means the `ANIM_keyingset_get_from_enum_type` will get it from the scene. > * If the scene doesn't have one, or a valid index isn't passed in the `KeyingSet` will be a `nullptr` in which case it inserts from the user preferences. LGTM. > One thing I was confused about at first is that the `enum` is passed in as a string from the python side, but received as an `int` on the C side. That's how RNA deals with many enums. The name of the enum item is used in Python, and gets mapped to an integer on the C/C++ side. You can find many examples of this mapping when you search in the RNA code for `EnumPropertyItem rna_`. > I am wondering if there is a way to deprecate a property so we can remove it in 5.0 Not really, apart from documenting the property as deprecated in its tooltip / description.
Christoph Lendenfeld merged commit b2aa36485b into main 2024-02-01 16:14:18 +01:00
Christoph Lendenfeld deleted branch fix_python_api_changes 2024-02-01 16:14:35 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117718
No description provided.