4
$\begingroup$

I saw that Blender 2.79 has the ability to save objects in properties using their id's. However, due to the limited documentation i can't figure out what i am doing wrong. I have included the code and the release notes where i found it below. Any help would be awesome!

class MyPropertyGroup(bpy.types.PropertyGroup):
        custom_1 = bpy.types.Object
        custom_2 = bpy.props.IntProperty(name="My Int")

    bpy.utils.register_class(MyPropertyGroup)

    bpy.types.Scene.id_objects = PointerProperty(type=MyPropertyGroup)

# Call doesn't work
bpy.context.scene.id_objects.custom_1 = bpy.data.objects[0]

https://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.79/PythonAPI#Blender_2.79:_Python_API

$\endgroup$

1 Answer 1

2
$\begingroup$
import bpy
scene = bpy.context.scene

class MyPropertyGroup(bpy.types.PropertyGroup):
    obj_pointer = bpy.props.PointerProperty(name="Object", type=bpy.types.Object)
    custom_2 = bpy.props.IntProperty(name="My Int")

bpy.utils.register_class(MyPropertyGroup)

bpy.types.Scene.id_objects = bpy.props.PointerProperty(type=MyPropertyGroup)

scene.id_objects.obj_pointer = bpy.data.objects[0]
print(scene.id_objects.obj_pointer.name)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .