2

I want to change the default_frames_limit in the movie clip editor. I found a script in a addon that does exactlie that:

clip = bpy.context.edit_movieclip
clip.tracking.tracks.data.settings.default_frames_limit = 10

But it just works from within the movie clip editor, not from a text editor script. How could I change this value from a different context?

Phönix 64
  • 720
  • 6
  • 24
  • 1
    I guess you'd like to run your script for a movie clip which is already loaded into the editor right? If so, I'd suggest to write a custom operator to call your "script" from F3 or to add a button to that editor, related: https://blender.stackexchange.com/questions/167862/how-to-create-a-button-on-the-n-panel/167870#167870 – brockmann Feb 14 '21 at 16:05
  • Thanks for the link might work it into a fully-fledged addon, fo now the answer below was helpful. – Phönix 64 Feb 14 '21 at 18:04

1 Answers1

4

Its the clip associated with the space.

Similarly to a text in the text editor, an image in the image editor, what is known as the context.clip in the movie clip editor, is the clip assigned to the space.

To the python console:

Loop thru the screens to find a movie clip area and return its active space.

>>> def get_clip():
...     for s in D.screens:
...         for a in s.areas:
...             if a.type == 'CLIP_EDITOR':
...                 return a.spaces.active
...     return None
...     
>>> mc = get_clip()
>>> mc
bpy.data.screens['Default.002']...SpaceClipEditor

The active clip of that space

>>> clip = mc.clip
>>> clip
bpy.data.movieclips['Batman_(1966)_S01E01.mkv']

>>> clip.tracking.tracks.data.settings.default_frames_limit 0

batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • As expected, good taste when it comes to movies. – brockmann Feb 14 '21 at 16:08
  • 1
    Here's a one-liner replacement for the get_clip function: mc = next((a for s in D.screens for a in s.areas if a.type == 'CLIP_EDITOR'), None). Not a fan of unreadable code like this, but sometimes you need a single statement (e.g. in drivers). – Markus von Broady Feb 14 '21 at 18:41