[Solved] Python Question: show floatproperty and template_ID in popup

I’ve been piecing together code and attempting to make a plugin. Forgive me if I use the wrong terminology, I’m still learning. I’ve hit a road block because I don’t fully understand how everything works within python.

currently I have a pie menu that runs different operators. When I click one of my operators, I would like to have a popup window that allows set some options (this part is working). I would also like it to list existing particle systems or materials. This is what I am having trouble with.

I’ve spent a lot of time search and reading code, but i’m just not getting it… any help would be greatly appreciated.

This is the Class I’ve created…


class DoThings(bpy.types.Operator):  
    bl_idname = "i.dothings"  
    bl_label = "I Do Things" 
    bl_options = {'REGISTER', 'UNDO'}
        
    string_prop = bpy.props.StringProperty(name="Subs", default="3")
    string_prop2 = bpy.props.StringProperty(name="inverts", default="4")
    string_prop3 = bpy.props.FloatProperty(name="Bevel Width", default=0.005, min=0.0001, max=1, step=0.01)
    string_prop4 = bpy.props.FloatProperty(name="Extrude Distance", default=0.005, min=0.0001, max=1, step=0.1)
    string_prop5 = bpy.props.FloatProperty(name="Extrude Distance", default=0.005, min=0.0001, max=1, step=0.1)

   
    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)
      
    def execute(self, context):
       #running my code 

        return {'FINISHED'}  


If I try to add something like ParticleSystems.active_index or active_material_index below my strings, it never shows up.

Ideally I would like to be able to make adjustments to the popup and have it update the object as I adjust. That is way past my skills, but would love any hints or direction. Right now I’m just using the text editor in blender which doesn’t give me a lot of output on error.

I think I figured it out. :wink:

I needed to add this before the execute

    def draw(self, context):
        cobj = bpy.context.object       
        layout = self.layout
        col = layout.column()
        col.prop(self, "string_prop", expand=True)
        col.template_ID(cobj, "active_material", new="material.new")
        col.prop(self, "string_prop2", expand=True)
        col.prop(self, "string_prop3", expand=True)
        col.prop(self, "string_prop4", expand=True)
        col.prop(self, "string_prop5", expand=True)


I think I understand how it works a little more… :slight_smile: