2
$\begingroup$

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?

$\endgroup$
2
  • 1
    $\begingroup$ 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: blender.stackexchange.com/questions/167862/… $\endgroup$ – brockmann Feb 14 at 16:05
  • $\begingroup$ Thanks for the link might work it into a fully-fledged addon, fo now the answer below was helpful. $\endgroup$ – Phönix 64 Feb 14 at 18:04
4
$\begingroup$

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
$\endgroup$
2
  • $\begingroup$ As expected, good taste when it comes to movies. $\endgroup$ – brockmann Feb 14 at 16:08
  • 1
    $\begingroup$ 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). $\endgroup$ – Markus von Broady Feb 14 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.