[SOLVED] v.2.57 dynamic selection pop-up

First of all, hello and thanks everybody!

we are working on the dynamic loading of materials in a customized pop-up.

Using dropdown list (EnumProperty) and loading the materials makes it
static in the class definition (users creations of new materials, does not appear obviously and that’s what we want).
We were diving in old posts, but solutions does not fit the problem under v.2.57.

We hope that with the new release, somebody knows to solve it, our try to help us giving advice.

thanks (for spending your time reading our problem, and trying to help us, we appreciate your effort)

Mikel

I add the code below (static):


import bpy

class tafco_opt_popup_cubo(bpy.types.Operator):

bl_idname = "prop.tafco_opt_popup_cubo"
bl_label = "Tafco POP-UP Add Cubo"
bl_options = {'REGISTER', 'UNDO'}
dialog_width = 400
 
tafco_nombre_cubo = bpy.props.StringProperty( name = "tafco_nombre_cubo" )
tafco_x_inicial_cubo = bpy.props.FloatProperty( name = "tafco_x_inicial_cubo",default = 0.0 )
tafco_y_inicial_cubo = bpy.props.FloatProperty( name = "tafco_y_inicial_cubo",default = 0.0 )
tafco_z_inicial_cubo = bpy.props.FloatProperty( name = "tafco_z_inicial_cubo",default = 0.0 )
tafco_x_final_cubo = bpy.props.FloatProperty( name = "tafco_x_final_cubo",default = 0.0 )
tafco_y_final_cubo = bpy.props.FloatProperty( name = "tafco_y_final_cubo",default = 0.0 )
tafco_z_final_cubo = bpy.props.FloatProperty( name = "tafco_z_final_cubo",default = 0.0 )

tafcoopciones = []
valor = 0
add = "mat"
for mat in bpy.data.materials:
    add = add + str(valor)
    tafcoopciones.append((add, mat.name, mat.type))
    valor = valor +1
    add= "mat"
  
tafco_material_cubo = bpy.props.EnumProperty( name = "Selección de Materiales", items = tafcoopciones, description = "Elige un material" )

def invoke(self, context, event):

    # cargar valores de materiales para el pop_up ????
    wm = bpy.context.window_manager
    wm.invoke_props_dialog(self, self.dialog_width)
    return {'RUNNING_MODAL'}

def draw(self, context):

    layout = self.layout
    scene = context.scene
 
    layout.label(text="Modificar para cambiar parámetros")
    layout.separator()
    col = layout.column()
    col.prop(self, 'tafco_nombre_cubo',text= "Nombre cubo")    
    layout.separator()
    split = layout.split()
    col = split.column()
    sub = col.column(align=True)
    sub.label(text="Parámetros iniciales")
    sub.prop(self, 'tafco_x_inicial_cubo', text= "Xi ")
    sub.prop(self, 'tafco_y_inicial_cubo', text= "Yi ")
    sub.prop(self, 'tafco_z_inicial_cubo', text= "Zi ")      
    col = split.column()
    sub = col.column(align=True)
    sub.label(text="Parámetros finales")
    sub.prop(self, 'tafco_x_final_cubo', text= "Xf ")
    sub.prop(self, 'tafco_y_final_cubo', text= "Yf ")
    sub.prop(self, 'tafco_z_final_cubo', text= "Zf ")    
    layout.separator()
    split = layout.split()
    col = split.column()
    col.prop(self, 'tafco_material_cubo', text= "Selección de Material ")
    layout.separator()    
    layout.label(text=" Creador: Tafco MW. Mikel")
    layout.label(text=" Tafco POP-UP Add Cubo V.1.0 ")
    layout.label(text=" Licencia GPL")


def execute(self,context):

    print ('Tafco: Ejecucion del boton OK del pop-up')
    return {'FINISHED'}

bpy.utils.register_class(tafco_opt_popup_cubo)