How can I access a custom property of an object from python, the suggestion Blender gives me if I pass the mouse over the custom properties named "prop",


get me this output in the console

>>> bpy.data.objects["Cube"].["prop"]
  File "<blender_console>", line 1
SyntaxError: invalid syntax

You just need to remove the dot, so the correct invocation is:


Python's subscription syntax doesn't use dot character.

Note: In Python terminology this is known as getitem rather then getattr access.


It is possible to store datablocks in "custom properties". I just did an experiment:

m = bpy.data.movieclips.load("bigbuckbunny.mp4")
bpy.context.scene["cliche free video"] = m

You can see it in the Scene tab of the Properties panel at the bottom. It appears to be preserved across a save/load cycle.

I'm not sure how many different datablocks support custom properties, but you might find one that is a better match than Scene (like an Object, or a Material).

I think you could even store an array of movieclips in there.


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.