Anim: add ensure parameter to KeyframeStrip.channels(...) RNA function
Add `ensure` boolean parameter to the `ActionKeyframeStrip.channels()` RNA
function. Passing `ensure=True` will ensure the channelbag for the given
action slot handle exists. This makes it more straight-forward to create
F-Curves for a slot regardless of whether there already was a channelbag
for those F-Cuves:
```python
strip = action.layers[0].strips[0]
slot = action.slots[0]
# Old:
channelbag = strip.channels(slot.handle)
if not channelbag:
channelbag = strip.channelbags.new(action_slot)
ob_loc_x = channelbag.fcurves.new('location', index=0)
# New:
channelbag = strip.channels(slot.handle, ensure=True)
ob_loc_x = channelbag.fcurves.new('location', index=0)
```
Pull Request: https://projects.blender.org/blender/blender/pulls/133678
This commit is contained in:
@@ -395,6 +395,10 @@ class ChannelbagsTest(unittest.TestCase):
|
||||
self.strip.channelbags.remove(channelbag)
|
||||
self.assertEqual([], list(self.strip.channelbags))
|
||||
|
||||
def test_ensure_channelbag(self):
|
||||
channelbag = self.strip.channels(self.slot.handle, ensure=True)
|
||||
self.assertEqual([channelbag], list(self.strip.channelbags))
|
||||
|
||||
def test_create_remove_fcurves(self):
|
||||
channelbag = self.strip.channelbags.new(self.slot)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user