I am in the process of writing a tool that makes uses of Sequences in the Sequence Editor. I was trying the following in my add-on (register() method)

Sequence.active = BoolProperty(name='Active', 
                               description='Is the custom property group active', 

After I launch Blender and try to assign a value to my custom property, I get the following error

>>> C.scene.sequence_editor.sequences[0].active = 1
Traceback (most recent call last):
AttributeError: 'SceneSequence' object attribute 'active' is read-only

So my question is: Is it possible in anyway to add a custom property to a Sequence?


Update: bpy.types.Sequence
Properties is supported in 2.75 (or recent builds)

The information below is kept since the answer still applies to types such as bpy.types.TimelineMarker or bpy.types.Modifier.

In short - no. You can only add custom data properties on:

  • ID (its subclasses Action, Armature, Brush, Camera, Curve, FreestyleLineStyle, GreasePencil, Group, Image, Key, Lamp, Lattice, Library, Mask, Material, Mesh, MetaBall, MovieClip, NodeTree, Object, PaintCurve, Palette, ParticleSettings, Scene, Screen, Sound, Speaker, Text, Texture, VectorFont, WindowManager, World', etc...)
    Try run: bpy.types.ID.__subclasses__() to see all.
  • Bones
  • PoseBones
  • AddonPrefs
  • Node, NodeSocket, NodeSocketInterface
  • OperatorProperties.

The reason this gives confusing output is that the initial assignment is using Pythons regular class assignment, in this case its not using a metaclass (which would interpret the property definitions and apply them as you are expecting).

bpy.types.Sequence.foobar = 22
# >>> 22
bpy.context.sequences[0].foobar = 11 # <-- will error!
# AttributeError: 'SceneSequence' object attribute 'foobar' is read-only

So why use this at all? - Because it allows you to add utility methods & properties at run-time. Note that this is standard python and nothing Blender specific (unlike custom properties).

bpy.types.Sequence.calc_frame_mid = (lambda seq:
        (seq.frame_final_start + seq.frame_final_end) / 2)


... you can add Python style properties too.

Note, adding methods and properties to existing data types is known as Monkey Patching and often considered bad practice, however you can also use this to dynamically build up functionality into classes you generate for instance, so it can be used in some interesting/useful ways too.

If you modify Blenders built in types it will make the changes globally so beware it could break other scripts or even make Blender fail to use its own API's correctly, so this is really advanced api usage.

|improve this answer|||||
  • $\begingroup$ +1 Thank you for the response and some insights into properties. I will look into this and see if i can implement a workable solution for my addon. $\endgroup$ – satishgoda Jun 18 '13 at 5:26
  • $\begingroup$ Thank you again for the extra note. Will keep that in mind and test accordingly. $\endgroup$ – satishgoda Jun 18 '13 at 15:24
  • 1
    $\begingroup$ Update, in 275 you can do this! $\endgroup$ – ideasman42 Apr 25 '15 at 14:20

Your Answer

