4

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

Ryan Grzesiak
  • 243
  • 1
  • 2
  • 10

1 Answers1

2
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)
Yurii Sivalnev
  • 149
  • 1
  • 11