2011-02-18 14:27:18 +00:00
|
|
|
"""
|
|
|
|
Collection Example
|
|
|
|
++++++++++++++++++
|
|
|
|
|
|
|
|
Custom properties can be added to any subclass of an :class:`ID`,
|
|
|
|
:class:`Bone` and :class:`PoseBone`.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import bpy
|
|
|
|
|
2011-02-25 16:19:50 +00:00
|
|
|
|
2011-02-18 14:27:18 +00:00
|
|
|
# Assign a collection
|
|
|
|
class SceneSettingItem(bpy.types.PropertyGroup):
|
|
|
|
name = bpy.props.StringProperty(name="Test Prop", default="Unknown")
|
|
|
|
value = bpy.props.IntProperty(name="Test Prop", default=22)
|
|
|
|
|
|
|
|
bpy.utils.register_class(SceneSettingItem)
|
|
|
|
|
|
|
|
bpy.types.Scene.my_settings = \
|
|
|
|
bpy.props.CollectionProperty(type=SceneSettingItem)
|
|
|
|
|
|
|
|
# Assume an armature object selected
|
|
|
|
print("Adding 3 values!")
|
|
|
|
|
|
|
|
my_item = bpy.context.scene.my_settings.add()
|
|
|
|
my_item.name = "Spam"
|
|
|
|
my_item.value = 1000
|
|
|
|
|
|
|
|
my_item = bpy.context.scene.my_settings.add()
|
|
|
|
my_item.name = "Eggs"
|
|
|
|
my_item.value = 30
|
|
|
|
|
|
|
|
for my_item in bpy.context.scene.my_settings:
|
2011-02-25 16:19:50 +00:00
|
|
|
print(my_item.name, my_item.value)
|