Collection Singleton

Hi dear forum, I’m using Collections to store my custom propreties of my addons.

My concern is, it’s creating an Collection array with

class customPropertyGroup(bpy.types.PropertyGroup):
    Order = StringProperty()
bpy.types.Scene.customCollection = bpy.props.CollectionProperty(type = customPropertyGroup)

How can I make it the way I don’t have to get my collection with

bpy.context.Scene.customCollection[0]

but

bpy.context.Scene.customCollections

Thanks

There’s something wrong with the names…

You need to register on bpy.types.Scene, but access via a scene instance, e.g. bpy.context.scene (with lower-case s!).

bpy.context.scene.customCollections will give you access to the collection, [0] should return the first entry in the collection.

I wonder if your concept is good, you can use a PointerProperty with a derived PropertyGroup class to organize several properties.Co
llections should really be used for a varying number of properties.

Sorry for these small mistakes. It was a quick example, I usually wright it right.

But I’m interested in this PointerProperty. Could you explain more bit?

It points to a PropertyGroup, it’s great to organize your properties in a namespace fashion, e.g.

bpy.context.scene.my_pointer_prop.my_prop

It’s covered in the API docs:
http://www.blender.org/documentation/blender_python_api_2_70_release/bpy.props.html#propertygroup-example

Also checkout AddonPreferences:
http://www.blender.org/documentation/blender_python_api_2_70_release/bpy.types.AddonPreferences.html

I did see this Property type, but I didnt figure it was what I was looking for.

Thanks CoDEmanX.