I need some help with properties. I have a property class, pretty straight forward stuff

class My_Settings(bpy.types.PropertyGroup):
    prop_1: bpy.props.IntProperty(name="Some prop", default=0)
    prop_2: bpy.props.IntProperty(name="Another prop", default=0)

I register the class and assign it to scene as

bpy.types.Scene.my_props = bpy.props.CollectionProperty(type=My_Settings)

I use another class to add instances of those properties:

class My_add_property(bpy.types.Operator):
    bl_idname = "add_fields"
    bl_label = "Add input fields"

    def execute(self, context):
        inst_prop = bpy.context.scene.my_props.add()
        inst_prop.prop_1 = 0
        inst_prop.prop_2 = 1
        return {'FINISHED'}

I draw a menu, use My_add_prop as a button to add instances

class My_menu(bpy.types.Panel):
    bl_idname = "my_menu"
    bl_label = "Menu"

    def draw(self, context):
        self.layout = lay
        lay.operator('add_fields', text="Add prop")

        '''But I have no idea how to access individual properties do draw them into menu.
         I assume it's going to be something like that, but how can I actually get to
         individual values?'''

        for i in bpy.context.scene.my_props:
            lay.prop(context.scene, "my_props")
            lay.prop(context.scene, "my_props")

Also, ts there a method to remove last property set? I'd like to make class/button that removes the last set. Thanks for help!


1 Answer 1


Well, I finally figured it out. the last block in the menu should look like that

 for i in bpy.context.scene.my_props:
        lay.prop(i, "prop_1")
        lay.prop(i, "prop_2")

Now i feel kind of stupid... Also if you want to go on removing last set of properties, you can go with


This appears to be removing sets of properties one by one until it hits the (1) one.

Hope it helps someone in the future!


You must log in to answer this question.

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