0
$\begingroup$

Neither bpy.context.space_data.display_channel = 5 nor bpy.types.SpaceSequenceEditor(display_channel = 5) seems to be working?

$\endgroup$
2
$\begingroup$

Make sure you have the correct context.

The context area needs to be a video sequencer. Quick console code, find the VSE and set the property from py console.

>>> for i, a in enumerate(C.screen.areas):
...     i, a.type
...     
(0, 'INFO')
(1, 'PROPERTIES')
(2, 'CONSOLE')
(3, 'VIEW_3D')
(4, 'SEQUENCE_EDITOR')

>>> C.screen.areas[4].spaces.active.display_channel
0

If your script is invoked via a button or menu in the VSE area use

space = context.space_data

or

space = context.area.spaces.active

If it is not a VSE area / space then you will get an error (unless another space has a display_channel property.

Each area can have at least one up to a space for each of the editor types. (SEQUENCER, CONSOLE, etc) The one you are seeing is the active one. area.spaces.active Others you have had active at some stage are stored in area.spaces.

EDIT:

Find all preview VSE's in screen, and set display channel.

previews = [a.spaces.active for a in context.screen.areas
        if a.type == 'SEQUENCE_EDITOR'
        and a.spaces.active.view_type == 'PREVIEW']

for s in previews:
    s.display_channel = 3

As for bpy.types.SpaceSequenceEditor(display_channel = 5) what is the expectation here?. Instancing from bpy.types classes is very rare, and is mostly done via a new or add method.

$\endgroup$
  • $\begingroup$ I tried to override the area type like this, but unsuccesful: import bpy area = bpy.context.area.type bpy.context.area.type = "SEQUENCE_EDITOR" bpy.context.space_data.display_channel = 5 bpy.context.area.type = area $\endgroup$ – tintwotin Dec 18 '18 at 11:49
  • $\begingroup$ This actually changes the channel, but with no effect in the VSE preview or UI: import bpy area = bpy.context.area.type bpy.context.area.type = "SEQUENCE_EDITOR" bpy.context.area.spaces.active.display_channel = 2 print(bpy.context.area.spaces.active.display_channel) bpy.context.area.type = area $\endgroup$ – tintwotin Dec 18 '18 at 11:59
  • $\begingroup$ Lets say you run that in the text editor, you are setting the value in the VSE space of the same area. (ie change from text editor to VSE in that area). It won't effect other areas. $\endgroup$ – batFINGER Dec 18 '18 at 12:00
  • $\begingroup$ Put in other words, it's a property of the space, like a 3D view's orientation. It is set on an individual space by space basis. A property of a sequencer will show on all VSE's like C.scene.sequence_editor.active_strip. $\endgroup$ – batFINGER Dec 18 '18 at 12:08
  • $\begingroup$ Oh, I simply can't get it to work. I'm sorry for not really being able to understand this stuff. What I'm trying to do is to use the mouse in the sequencer to select what channel to be shown as solo(and written in the channel selector in the preview monitor header), until right mouse or esc are pressed. Here's my code: pasteall.org/1435568/python $\endgroup$ – tintwotin Dec 18 '18 at 13:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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