1
$\begingroup$

Could someone please explain, line for line how this script works; in particular the dots in between the setting definitions s.proxy.build_50

import bpy

for s in bpy.context.scene.sequence_editor.sequences:
    if s.type != 'SOUND':
        s.use_proxy = True
        s.proxy.build_25 = True
        s.proxy.build_50 = False
        s.proxy.build_75 = False
        s.proxy.build_100 = False

I'm most interested in understanding how one finds out how to define other settings/switches.

I know you can right click on for online Python reference. Also hover over them to see a bit of code; but looking at these has just confused me.

Is there a list of other settings / code to define them?

$\endgroup$
2
$\begingroup$

bpy.context.scene.sequence_editor.sequences is a list like:

list = ["a", "b", "c"]
for element in list:
    print( element )

this would print:

a
b
c

the for loop assigns each element from the list to a variable executes the commands (print in this case) and advances to the next element.

The same applies to your snippet s gets on value after another from the defined sequences. Adding a print statement before the if statement would show something like that:

<bpy_struct, ImageSequence("main_chart.jpg")>
<bpy_struct, ImageSequence("main_chart.jpg")>
<bpy_struct, SoundSequence("sound.wav")>

Now you know the name of the classes (ImageSequence or whatever is printed) and you can lookup the API Documentation

The dot is a syntax element that separates the name of an object by its properties.

You could also examine the available properties by using dir

print( dir(s) )

Which would print for an ImageSequence:

['__doc__', '__module__', '__slots__', 'alpha_mode', 'animation_offset_end', 
'animation_offset_start', 'bl_rna', 'blend_alpha', 'blend_type', 'channel', 
'color_multiply', 'color_saturation', 'colorspace_settings', 'crop', 'directory', 'effect_fader', 'elements', 'frame_duration', 'frame_final_duration', 
'frame_final_end', 'frame_final_start', 'frame_offset_end', 'frame_offset_start', 'frame_start', 'frame_still_end', 'frame_still_start', 'lock', 'modifiers', 'mute', 'name', 'proxy', 'rna_type', 'select', 'select_left_handle', 'select_right_handle', 
'speed_factor', 'strip_elem_from_frame', 'strobe', 'swap', 'transform', 'type', 
'update', 'use_crop', 'use_default_fade', 'use_deinterlace', 'use_flip_x', 
'use_flip_y', 'use_float', 'use_linear_modifiers', 'use_proxy', 'use_proxy_custom_directory', 'use_proxy_custom_file', 'use_reverse_frames', 'use_translation']

Related:

$\endgroup$
3
$\begingroup$

bpy.context.scene refers to the current scene, e.g. bpy.data.scenes["Scene"]

Sequence Editor data is stored in the Scene type, and .sequences contains the the top-level strips.

This iterates over all top-level sequences, whereas s refers to a sequence:

for s in bpy.context.scene.sequence_editor.sequences:

If the sequence is of type SOUND:

    if s.type != 'SOUND':

... the following code block is executed:

        s.use_proxy = True
        s.proxy.build_25 = True
        s.proxy.build_50 = False
        s.proxy.build_75 = False
        s.proxy.build_100 = False

A couple sequence properties are set.

Other sequence types:

>>> [item.identifier for item in bpy.types.Sequence.bl_rna.properties['type'].enum_items]

['IMAGE', 'META', 'SCENE', 'MOVIE', 'MOVIECLIP', 'MASK', 'SOUND', 'CROSS', 'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED', 'MULTICAM', 'ADJUSTMENT']

You can pick a single sequence and get the type:

>>> type(bpy.context.scene.sequence_editor.sequences[0])
<class 'bpy.types.SceneSequence'>

Check the API docs to find out about the properties and methods: bpy.types.SceneSequence

.proxy is a subtype, which has several own properties: bpy.types.SequenceProxy

Don't miss to read this:

Blender/Python API Reference Usage: examples of how to use the API reference docs

$\endgroup$

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.