Maniphest T93982

bpy: fcurve.is_valid wrong result if user didn't display dopesheet first
Closed, Archived

Assigned To
None
Authored By
Julien DUROURE (julien)
Dec 12 2021, 6:13 AM
Tags
  • BF Blender
  • Python API
Subscribers
Julien DUROURE (julien)
Philipp Oeser (lichtwerk)
Scurest (scurest)
Sybren A. Stüvel (sybren)

Description

System Information
Operating system: Mint
Graphics card: Nvidia 860m

Blender Version
Broken: 3.0
Worked: ?

Short description of error
fcurve.is_valid wrong result if user didn't displayed dopesheet first, when curve is not valid

Exact steps for others to reproduce the error
Based on the default startup or an attached .blend file (as simple as possible).

  • Open attached file.
  • Open a python console screen
  • type bpy.context.object.animation_data.action.fcurves[0].is_valid --> Return True
  • Open DopeSheet. You can see that fcurves are not valid
  • type bpy.context.object.animation_data.action.fcurves[0].is_valid again --> Return False

This should return false even if user didn't display curves, when open a blend file.

Event Timeline

Julien DUROURE (julien) created this task.Dec 12 2021, 6:13 AM
Julien DUROURE (julien) added a project: Python API.
Julien DUROURE (julien) updated the task description.Dec 12 2021, 6:22 AM
Scurest (scurest) added a subscriber: Scurest (scurest).Dec 12 2021, 7:26 AM

I don't think that's really possible. Whether an action's fcurve is valid depends on what the action is applied to, not on the fcurve itself. For example, assign the cube's action to the armature too. Then the fcurve is valid for the arma but not the cube. Now when you look at the cube in the dope sheet, the fcurve gets a red underline and is_valid changes to false. But switch to the armature, and the red underline goes away, and is_valid changes to true.

If the fcurve is valid for one object, but not for another, a single boolean is_valid can't capture that. The only thing it could do is cache the result of the last time it was checked, so there's no reasonable state before the first check.

In fact, looking at when both the cube and arma are displayed in the dope sheet, I'm pretty sure is_valid just caches whether it got a red underline the last time it was drawn. Literally, the "last time", changing the sort order or resizing the window will change it. So it's not really for answering "is this fcurve valid for this object", which is what you want for T93704.

Philipp Oeser (lichtwerk) closed this task as Archived.Jan 5 2022, 3:19 PM
Philipp Oeser (lichtwerk) added subscribers: Sybren A. Stüvel (sybren), Philipp Oeser (lichtwerk).

Thx @Scurest (scurest) for the investigation.

Think this explains it quite well. We need an ID in order to make sense of the is_valid of an fcurve.
Querying this on the bare fcurve from py/RNA does not make too much sense.
Only thing I could think of is making this a function (instead of just the property which reads the FCURVE_DISABLED flag gets set in animation editors).
That function could be passed an ID then.

That being said, such a function would be a request for improved behavior and not a bug in the current code (@Sybren A. Stüvel (sybren): correct me if I am wrong)

For user requests and feedback, please use other channels: https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests
For more information on why this isn't considered a bug, visit: https://wiki.blender.org/wiki/Reference/Not_a_bug

Afraid we have to close, thx reporting anyways!