I am unable to get the collection property to work. Any suggestions please as to what i may be doing wrong …
import bpy
class MyCustomProperty(bpy.types.PropertyGroup):
map = bpy.props.StringProperty()
class MyCustomPropertyCollection(bpy.types.PropertyGroup):
bl_idname = __name__
mapCollection = bpy.props.CollectionProperty(type=MyCustomProperty)
class MyPanel(bpy.types.Panel):
bl_label = "My Panel"
bl_idname = "my_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_category = "Library Texture List"
bl_context = "objectmode"
t_slotList = 1
def draw(self, context):
m = bpy.context.scene.maps
layout = self.layout
layout.operator("collection.add_map", icon='ZOOMIN', text="")
for i in enumerate(m.mapCollection):
a = layout.prop_search(context.scene, str(m.mapCollection[i].map), bpy.data, "textures", icon='TEXTURE_DATA')
a.tex_index = i
class dummyOperator(bpy.types.Operator):
bl_label = "Operator for appending"
bl_idname = "collection.add_map"
tex_index = bpy.props.IntProperty()
def execute(self, context):
scene_name = bpy.context.scene.name
bpy.data.scenes[scene_name].maps.mapCollection[self.tex_index].add()
return {"FINISHED"}
def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.maps = bpy.props.PointerProperty(type = MyCustomPropertyCollection)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()