Page MenuHome

Use appropriate context for the DopeSheet Action Custom Properties panel.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Jun 24 2022, 4:12 PM.

Details

Summary

Refactor D14646 to use context.active_action for the Action
Custom Properties panel, matching the already existing Action panel.

This has the advantage that it allows access to the properties of
any actions with channels visible in the Dope Sheet, e.g. Shape Keys,
Materials etc; while using just the active object is limited to just
the object animation.

Also move both panels from Item to the Action tab.

Diff Detail

Repository
rB Blender

Event Timeline

Alexander Gavrilov (angavrilov) requested review of this revision.Jun 24 2022, 4:12 PM
Alexander Gavrilov (angavrilov) created this revision.

One possible thing to also think about is whether the tab should be called Item, or if e.g. Action would work better for both of these panels.

Other than code consistency, what's the reason to use selected_visible_actions[0] instead of active_object.animation_data.action? In other words, which concrete problem is solved by this?

One possible thing to also think about is whether the tab should be called Item, or if e.g. Action would work better for both of these panels.

I think "Action" would indeed be better.

Each panel/UI element shouldn't have to create a list only to select the first one, if multiple panels do this it could cause noticeable performance problems if there are many actions selected.

Shouldn't the active action be used in this case as is done elsewhere?

release/scripts/modules/bpy_types.py
63 ↗(On Diff #52876)

The convention for built-in scripts is to use % formatting.

66 ↗(On Diff #52876)

Non-integer values (such as slice or bad input) will error here.

There should be a check for non-integer values (if int fails).

Shouldn't the active action be used in this case as is done elsewhere?

There is no "active action" in dopesheet (is there even an 'active channel'?). The list collects all actions associated with the selected animation channels without duplicates. In the Action Editor it is always at most 1 item and returns the action from the header.

Of course it is possible to add a single item 'active action' property that is in practice equivalent to selected_visible_actions[0] (but returns immediately once something is found) if you think it's important.

Other than code consistency, what's the reason to use selected_visible_actions[0] instead of active_object.animation_data.action? In other words, which concrete problem is solved by this?

Because Dopesheet Editor isn't limited to the active object. This list is built based on selected channels, so you can access properties of any actions for which you can see channels there. Think about animations attached to other datablocks like shape keys, materials etc. This context property is an universal solution for all of them.

release/scripts/modules/bpy_types.py
66 ↗(On Diff #52876)

The isdigit check is supposed to test for that, unless you mean integer overflow or something.

Of course it is possible to add a single item 'active action' property that is in practice equivalent to selected_visible_actions[0] (but returns immediately once something is found) if you think it's important.

I think that's a good idea.

Other than code consistency, what's the reason to use selected_visible_actions[0] instead of active_object.animation_data.action? In other words, which concrete problem is solved by this?

Because Dopesheet Editor isn't limited to the active object. This list is built based on selected channels, so you can access properties of any actions for which you can see channels there. Think about animations attached to other datablocks like shape keys, materials etc. This context property is an universal solution for all of them.

👍

This should be explained in the patch description as well, then.

Sybren A. Stüvel (sybren) requested changes to this revision.Jul 7 2022, 12:02 PM
This revision now requires changes to proceed.Jul 7 2022, 12:02 PM

I have split the context changes into separate patches:

  • Adding a native active_action property as D15412.
  • Supporting indexing in path_resolve as D15413 - with active_action it won't be needed by this patch anymore, but I think it should be added for completeness anyway.

This patch will only contain changes to DOPESHEET_PT_custom_props_action once D15412 is accepted.

This revision is now accepted and ready to land.Jul 19 2022, 4:09 PM