Creating a adaptative popup

Hi,

I’m trying to create a popup with a specified number of line, (number of objects in the scene) but I have difficulties.

Here is my code :

import bpy
from bpy.props import *


class LocationManager(bpy.types.Operator):
    bl_idname = "object.location_operator"
    bl_label = "Manage location on anchors"
    
    male_string = bpy.props.StringProperty( \
        name="Male locations", \
        description="Here enter the locations, separated by commas" \
        )
    


    def execute(self, context):  
        #TODO : manage the results
        return {'FINISHED'}


    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_dialog(self, 500, 500)
  
    def draw(self, context):
    
        #test datas
        objects = [obj for obj in bpy.context.scene.objects if obj.type == 'EMPTY']


        col = self.layout.column()
        col.prop(self, "male_string")
        self.layout.separator()
        
        col.label("Female locations")
                # ####HERE I want to add on StringProperty by obj####
        for obj in objects:
            self.female_string = bpy.props.StringProperty(name="Female locations",description="Here enter the locations, separated by commas")
            col.prop(self, "female_string")
    
#
#   The OK button in the dialog
#
class OnErrorOk(bpy.types.Operator):    
    bl_idname = "location.validation"
     
    def execute(self, context):
        return{'FINISHED'}  


bpy.utils.register_class(LocationManager)




# test call : for debug usage
bpy.ops.object.location_operator('INVOKE_DEFAULT')

The for loop seems not to add a new StringProperty by objects… Here is my main issue.

Thanks a lot for any advice/solution :slight_smile:

Here is an improvement :



class LocationManager(bpy.types.Operator):
    bl_idname = "object.location_operator"
    bl_label = "Manage location on anchors"
    
    male_string = bpy.props.StringProperty( \
        name="Male locations", \
        description="Here enter the locations, separated by commas" \
        )
    




    femal_str = [
    bpy.props.StringProperty( \
       name="Female locations 0 ", \
       description="Here enter the locations, separated by commas" \
       ),
    bpy.props.StringProperty( \
       name="Female locations 1 ", \
       description="Here enter the locations, separated by commas" \
       ),
    bpy.props.StringProperty( \
       name="Female locations 2 ", \
       description="Here enter the locations, separated by commas" \
       ),
    bpy.props.StringProperty( \
       name="Female locations 3 ", \
       description="Here enter the locations, separated by commas" \
       ),
    bpy.props.StringProperty( \
       name="Female locations 4 ", \
       description="Here enter the locations, separated by commas" \
       ),
    bpy.props.StringProperty( \
       name="Female locations 5 ", \
       description="Here enter the locations, separated by commas" \
       ),
    bpy.props.StringProperty( \
       name="Female locations 6 ", \
       description="Here enter the locations, separated by commas" \
       )   
    ]

Then I’m trying to add them in the layout… but it is not working of course…

 def draw(self, context):    
        #test datas
        objects = [obj for obj in bpy.context.scene.objects if obj.type == 'EMPTY']


        col = self.layout.column()
        col.prop(self, "male_string")
        self.layout.separator()
        
        col.label("Female locations")
        i = 0
        for obj in objects:
            col.prop(self, self.femal_str[i].name())
            i = i+1

Any help would be apreciated :slight_smile:

Regards,
Vince

Please… nobody ever done something similar ?
Thanks.

Try a CollectionProperty()