If the user renames an object, the reference via string key is lost.

Is it possible to store a pointer to an object in a property assigned to a class of bpy.types

I checked

>>> type(obj.bl_rna.properties['parent'])
<class 'bpy.types.PointerProperty'>  

However type for PointerProperty is expected to be a subclass of bpy.types.PropertyGroup but bpy.types.Object is inherited from bpy_struct and bpy.types.ID.


3 Answers 3


No, despite the sound of PointerProperty, its purpose is not to store a pointer/reference to an ID datablock. Update: you can use it to reference ID datablocks in Blender 2.79 and above, see the other answer.

It's used to organize a set of properties in a nice way, especially if your addon registers a lot of properties:

# Bad, clutters scene objects and may even conflict with other addons
bpy.types.Scene.my_prop_1 = bpy.props.IntProperty()
bpy.types.Scene.my_prop_2 = bpy.props.IntProperty()
bpy.types.Scene.my_prop_3 = bpy.props.IntProperty()

# Good, organize properties as a group
class MyAddonProperties(bpy.types.PropertyGroup):
    my_prop_1 = bpy.props.IntProperty()
    my_prop_2 = bpy.props.IntProperty()
    my_prop_3 = bpy.props.IntProperty()

bpy.types.Scene.my_addon = bpy.props.PointerProperty(type=MyAddonProperties)

# Access it e.g. like


What you are looking for is bpy.props.IDProperty, but we don't have that (shame!)

These kind of properties need to be created in C, like Object.parent.

In Python, you can only store by name (StringProperty). Use it together with a CollectionProperty and layout.prop_search().

Note: The StringProperty isn't tied to the object's name. It's possible to abuse app handlers to check for name changes and to update the property accordingly, but I wouldn't consider it very safe nor efficient.

  • $\begingroup$ blender.stackexchange.com/questions/7973/… has an example of doing this with StringProperty. $\endgroup$
    – neodelphi
    Mar 1, 2018 at 18:46
  • $\begingroup$ So in a nutshell: use PropertyGroup / PointerProperty for custom properties attached to bpy._types_ and use CollectionProperty to add custom properties to objects. Thanks CoDEmanX, that clarified things for me! $\endgroup$ Jul 27, 2018 at 3:21

As of release 2.79 it is possible to store a pointer to an object

Usage example:

my_pointer = PointerProperty(name="My Pointer", type=bpy.types.Object)

We can add pointer property to store a object, and scenes, textures and all other data types in 2.79 version

bpy.types.Scene.MyPointer = bpy.props.PointerProperty(name = "my pointer", description = "my descr",
type=bpy.types.Texture) #add a texture pointer


bpy.types.Scene.MyPointer = bpy.props.PointerProperty(name = "my pointer", description = "my descr",
type=bpy.types.Mesh) #add a mesh pointer

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.