Create custom property for sequencer strip in python

i'm trying to write a little addon for the sequencer in blender. I want to create a kind of custom category of clip easily accessible through ui panel (like "reference clip" which are not going to be rendered, for example) I'm trying to use custom property for this, so long so good for iterate and finding them through the timeline, but i'm having hard time at creating the custom property through python... Here's what i've got so far :

    import bpy

scene = bpy.context.scene
strip = scene.sequence_editor.sequences_all
activeST = scene.sequence_editor.active_strip

if activeST is not None:
if len(activeST.keys()) > 1:
for CP in activeST.keys():
if CP in "___reference_strip":
print("Active strip is already a Reference Strip")
else :
activeST['___reference_strip'] = 1.000
else :
activeST['___reference_strip'] = 1.000


After creating the property with this piece of code, i'm trying to perform action, like mute strip with this property :

scene = bpy.context.scene
strip = scene.sequence_editor.sequences_all

for S in strip:
if len(S.keys()) > 1:
for CP in S.keys():
if CP in "___reference_strip":
S.mute = True


the custom property is created, but doesn't seem to be active, but the code above doesn't select mute the clip with it, i have to manually edit it to make it work...

Any help to find the origin of the problem would be greatly appreciated :D

• Confused at what you are asking here. Do you want code to make strip active if it has the key? To see if strip has ref cust prop could use is_ref = "__reference_strip" in active_strip.keys() May 15, 2017 at 13:00
• Hi thanks for the answer, sorry if i wasn't clear, i managed to access some "tagged" strip (tagged with specific custom property like "___reference_strip") and perform specific action, but i want to be able to create these properties through python on active strip. For now, i tried using activeST['___reference_strip' = 1.000 , but property created seems inactive... Is it clearer ? :) May 15, 2017 at 13:41
• Can you describe what is: active / inactive property? May 15, 2017 at 16:11
• custom property is visible in the interface, but when you call it through python, doesn't seem to exists. I have to manually edit it, then it works perfectly ! May 15, 2017 at 16:39

You're going to have to provide a code sample that can be used to illustrate/trigger the problem you are having. I wrote the following bit of code and it worked exactly as I expected:

import bpy
scn = bpy.context.scene
strip = scn.sequence_editor.active_strip
strip['anchovy'] = 3.3
x = [ s for s in scn.sequence_editor.sequences_all if s.get('anchovy') is not None ]
print(x)
print( [ s.get('anchovy') for s in scn.sequence_editor.sequences_all ] )


As you can see, I was able to select a clip based on the property (list comprehension x).

• I'm not working right now but this code seems to work with the 'get' command, i updated my first question to show you what exactly i tried to achieve, with 'key' attribute. But your solution seems perfect, i'll try soon with my script and make your answer the good one ! thanks a lot ! and do you know why it doesn't work with 'key' attribute ? May 15, 2017 at 20:43
• is it possible that you only have 1 custom property, and therefore len(S.keys() ) > 1 is false? May 15, 2017 at 20:56
• oh... You're absolutely right, i copy paste this piece of code from somewhere, and didn't pay attention to that... sorry for being so newbie in python^^ thank you very much for your answers ! May 15, 2017 at 23:14